Hi,
I have the issue that an Object I set to inactive , wont get active again with yield return new WaitForSeconds.
What do I do wrong here? I call the IEnumerator Activate function but I cannot reach the code after WaitForSeconds?
Please help! I am struggling with this since two days and I tried so much already… I am out of ideas.
Thanks!
public GameObject docu;
public GameObject document;
public GameObject reticle;
private void Start()
{
reticle = GameObject.Find("UI/ReticleCanvas/Reticle");
document = GameObject.Find("UI/Stats/Document");
docu = GameObject.FindGameObjectWithTag("Docu");
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "Player")
{
Destroy(docu);
document.SetActive(true);
Deactivate(reticle);
Destroy(document, 5);
// Code works perfectly until here!
StartCoroutine(Activate(reticle));
}
}
void Deactivate(GameObject g)
{
Debug.Log("GO INTO DEACTIVATE FUNCTION AND DEACTIVATE RETICLE!");
g.SetActive(false);
}
IEnumerator Activate(GameObject g)
{
Debug.Log("GO INTO ACTIVATE FUNCTION!");
// my trouble maker :(
yield return new WaitForSeconds(5);
Debug.Log("ACTIVATE RETICLE AFTER AFTER 5 SECONDS!");
g.SetActive(true);
}