I have been working on this problem for hours to no avail. Below you will see I have an if/else statement in my OnTriggerStay2D function. The first part works fine, but if my player leaves the trigger object the else statement doesn’t read.
Any help is appreciated!
public LevelManager tLM;
public bool inCrateLight;
void OnCollisionStay2D(Collision2D other)
{
if (other.gameObject.tag == "KillPlane")
{
if (inCrateLight)
{
Debug.Log("Incratelight can't die!");
}
else if (inCrateLight == false)
{
Debug.Log("Collision detected");
tLM.Respawn();
}
}
}
void OnTriggerStay2D(Collider2D other)
{
if (inCrateLight)
{
if (other.tag == "CrateLight")
{
Debug.Log("In Crate Light");
inCrateLight = true;
}else{
inCrateLight = false;
}
}
}