- Home /
Question by
swatmaster69 · Nov 01, 2012 at 05:49 AM ·
collisionontriggerenterontriggerexit
Why would OnTriggerEnter get called, but not OnTriggerExit?
I have a stationary capsule collider with IsTrigger set to true and a character controller that rolls into the collider to display a GUI button. Neither has a rigid body attached. The documentation says that neither OnTriggerEnter nor OnTriggerExit should get called unless at least one object has a rigid body, but OnTriggerEnter is definitely getting called, while OnTriggerExit isn't.
Edit: C# script included below.
void OnTriggerEnter(Collider collider)
{
WidgetStatus playerStatus = collider.GetComponent<WidgetStatus>();
if (playerStatus == null)
{
return;
}
isTriggered = true;
}
void OnTriggerExit(Collider collider)
{
WidgetStatus playerStatus = collider.GetComponent<WidgetStatus>();
if (playerStatus == null)
{
return;
}
isTriggered = false;
}
Comment
Are you sure it never gets called? Place a Debug.Log as the first statement.
I tried that. It never gets called. (I actually took the Log line out of the code above to keep it short.)