This commit is contained in:
Gerard Gascón 2025-04-24 14:23:29 +02:00
commit bd5b1556ff
269 changed files with 6249829 additions and 0 deletions

View file

@ -0,0 +1,37 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TriggerEnableAndDisable : MonoBehaviour{
public GameObject enable;
public GameObject disable;
public float delay;
void OnTriggerEnter2D(Collider2D col){
if(col.gameObject.tag == "Player"){
if(delay == 0){
if (enable != null){
enable.SetActive(true);
}
if (disable != null){
disable.SetActive(false);
}
gameObject.SetActive(false);
}else{
StartCoroutine(Delay());
}
}
}
IEnumerator Delay(){
yield return new WaitForSeconds(delay);
if (enable != null){
enable.SetActive(true);
}
if (disable != null){
disable.SetActive(false);
}
gameObject.SetActive(false);
}
}