Enemy Collisions With player

I was wondering why the enemies die when they collide with the player object. The player itself has no DamageDealer attached - when I Debug.Log on the OnTriggerEnter2D for Enemy and Player, only the player registers the damage - so why does the enemy still die?

1 Like

Hi Brody,

I was wondering the same thing. If you have the answer to that, would you mind sharing it here?

Thank You

Edit:

I figured out the reason. It’s because of the Hit() method in the DamageDealer script. I feel so silly. Just like our missiles get destroyed when coming in contact with the player or the enemy’s colliders, so do the enemies. This is because the Hit() method gets called in the script when the trigger collision event takes place which destroys the gameobject it is attached to (in this case, the enemies).
Just putting this here in case if anyone has the same issue in the future.

Cheers!

3 Likes

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

Privacy & Terms