Hi,
I added a rigid body to my player that I can control and move around the arena. I have the following C# Script which detects if my player has 'stayed' or 'exited' the Plane game object:
public float x = 0;
//...
void OnTriggerStay(Collider other)
{
if ( x <= 50 ) x++;
}
void OnTriggerExit(Collider other)
{
// does happen when below is commented but not vise versa
Debug.Log("outside of Plane");
//if ( x < 50 && > 0 ) x--;
}
Just wondering why.
What I don't want to do is this:
//...
bool isHere = false;
void UpDate()
{
if (isHere == false) x--;
}
void OnTriggerStay(Collider other)
{
isHere = true;
}
void OnTriggerExit(Collider other)
{
Debug.Log("leaving plane..");
isHere = false;
}
Which works, but can this be done only in the subrountine OnTriggerExit? I am all ears.