I have a situation where I am using yield WaitForSeconds in a function and about 50% of the time it works fine and 50% it seems to stop the rest of the function after it from working. I use yield WaitForSeconds in a number of other places in my script and it works just fine. It’s only in this function that I’m having the issue with it. Is there something about how it works that I’m not understanding? Here is my current code:
function OnTriggerEnter (theCollision : Collider)
{
if(theCollision.gameObject.tag == "homePoint")
{
if(characterHome)
{
Deactivate();
transform.position = homePoint.transform.position;
Debug.Log("Testing");
yield WaitForSeconds(1);
Debug.Log("Done waiting");
homeBox.SendMessage("LoadCharacter");
homeBox.SendMessage("SetCharacter");
characterHome = false;
}
}
}
Thanks in advance for any help.