hi guys, i need help with something, i’m a bit of a newbie to C#, and i’m developing a horror video game.
One of the things I want this code to do is to make is when the player goes through a trigger ( static bool in other Sript) certain lights ( in an array) turn off for a few seconds and then reappear, it sounds simple, doesn’t it? The point is that I do not know why this code sometimes works and sometimes it does not, in fact lately the number of times it is not working is more. Then I leave the code. I hope you can help me. Even if you know of a better or more optimized, or less bugged way to do this, I would also be very grateful if you would let me know. Greetings friends, thank you very much in advance.
public class ParpadearLuces : MonoBehaviour
{
public GameObject[] _LucesSubterraneo;
public GameObject craneo;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (CalaveraTrigger.apagarLuces==true)
{
StartCoroutine(esperar10Segundos());
}
void ApagarLuces()
{
for (int i = 0; i < _LucesSubterraneo.Length; i++)
_LucesSubterraneo*.SetActive(false);*
}
IEnumerator desaparecerCraneo()
{
yield return new WaitForSeconds(1);
craneo.SetActive(false);
for (int i = 0; i < _LucesSubterraneo.Length; i++)
LucesSubterraneo*.SetActive(true);
CalaveraTrigger.apagarLuces = false;
Destroy(this);
_}*
IEnumerator esperar10Segundos()
{
yield return new WaitForSeconds(10);
ApagarLuces();
StartCoroutine(desaparecerCraneo());
}
}
}