- Home /
OnTriggerEnter works once, OnTriggerExit not at all?
Hi I have the player controlling a cube with a box collider and rigdidbody. When the player mesh collides with the sheep mesh I get the message "Collision Detected" but when I leave the area of the sheep mesh I do not get the message "Left Collison".
void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag == "sheep")
Debug.Log ("Collision Detected");
}
void onTriggerExit(Collider other)
{
if(other.gameObject.tag == "sheep")
Debug.Log ("Left Collison");
}
The sheep objects have sphere colliders and sheep tags. Why is it not detecting when I have left the area of the sheep objects?
It is one of the major reasons why triggers or collisions don't work for many people.
The others being lack of rigidbody, setting "IsTrigger" (or not), using the wrong function signature, not checking the correct tag of the colliding object.... basically, not reading the documentation ;)
Answer by DBar · Aug 19, 2014 at 08:27 AM
Indeed tanoshimi. Collisions works. We have overflow malfunction somedays. Ouch.
Your answer
Follow this Question
Related Questions
walk through an object once 0 Answers
Can someone please tell me why this code isn't working? 1 Answer
OnTriggerEnter function in c# 0 Answers
Make object react to certain triggers only 1 Answer
OntriggerEnter / Stay with the same Gameobject tags 0 Answers