Hi!
I got a problem using OnTriggerExit2D on a fast moving object.
I have a circle collider that moves with the mouse cursor, and some circle colliders that are in some balls that keep falling on the scene with gravity.
When the circle collider that moves with the mouse colide with the falling balls I need to change the colors of the balls and when the colllider leaves I need to change the color again So I got:
void OnTriggerEnter2D (Collider2D other) {
fallingball.material.renderer.color = color.black;
}
void OnTriggerExit2D (Collider2D other) {
fallingball.material.renderer.color = color.white;
}
What happens is that when I move the mouse with the collider the OnTriggerExit does not get called. But if I freeze the mouse and wait the ball to get out from the collider the trigger is called.
I already try to move this code to the falling ball and still the OnTriggerExit does not get called.
I’m thinking that this class does not work with faster moving objects, am I correct**?**
If it so there is another way to do this**?**
If we had a way to make a IF statemant that check the collision inside the update class, I think that should do the trick.