I am making a script where an object should disappear after 2 seconds and when it does it sets a bool named “canDraw” to false and then after 1 second it should set the bool back to true but for some reason it never sets it back to true! I have been trying to figure out what i’ve been doing wrong for a while now and still can’t figure it out Please help!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Dissapear : MonoBehaviour {
public static bool canDraw = true;
public GameObject objectToActivate;
private void Start()
{
StartCoroutine(ActivationRoutine());
}
private IEnumerator ActivationRoutine()
{
yield return new WaitForSeconds(2);
objectToActivate.SetActive(false);
canDraw = false;
yield return new WaitForSeconds(1);
canDraw = true;
}
public void Update()
{
if (canDraw == false)
{
objectToActivate.SetActive(false);
}else
{
objectToActivate.SetActive(true);
}
}
}