- Home /
OnTriggerEnter2d() Not Triggering While Animating.
Hello all you wonderful people, I know you guys answer this question all the time, but I have checked here, here and here, yet to no avail. I have an OnTriggerEnter2D problem...
I have a player object who has a Box Collider2D, and a RigidBody2D(below)
I need it to be able to collide with my Enemy, who also has a BoxCollider2D which is set as a trigger. But is set to be animating while they collide with the player. When I watch this collision in the scene view, the collider is still active while the sprite animates. Here is the Enemy Collider
Here is the Enemy Animator
And here is my OnTriggerEnter2d() Which is a component on my Enemy prefab.
void OnTriggerEnter2D(Collider2D col)
{
Debug.Log("Collided");
if (col.gameObject.CompareTag("Player"))
{
Debug.Log("Player Collided");
gameOver.Invoke();
}
}
gameOver is a UnityEvent. When I play this and my player and enemy collide, nothing happens! No Debug message at all, nada.
The enemy and the player are set to the same layer, below is my collision matrix:
I'm not sure what else I could be missing, any help or suggestions would be very (very very) welcome. Thanks for your time in advance.
Answer by NootNootGames · Mar 06, 2020 at 10:24 AM
May be a stupid answer, but are you sure you didn't forget to add the "Player" tag to your player? Happened to me a couple of times lol.