Player destroys enemy when in contact

I made my 3rd enemy and now when I move the player and it comes in contact with any enemy, the enemy disappears ( but it still takes health points from the player which is good ). I’m not sure what to do. I thought of maybe adding an if statement in Enemy’s OnTriggerEnter2D to verify if the object is the player but I don’t really know how to do that…

Hi Emilia,

Does the player have a unique name such as “Player” or does it have a unique component such as PlayerHealth, Movement or something like that? If so, you could check that in an if-statement.

Hello! Actually, I think I solved the problem. For each enemy in the collider component, I had IsTrigger selected and now it works. Thank you so much for your support!

Good job on solving the problem! :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms