Hey all, newbie here
I am trying to make a basic 2D platformer and getting help from a book named “Unity 2D game development”
So I have a bullet prefab with box2D, and a collider for my enemy object. Using events and delegates for hit detection script(Know it’s an overkill, just book stated so)
Problem is, when I am shooting an enemy, it doesn’t always kill him despite the simple Destroy(gameObject, 0.1f) command. Sometimes it hits and kills, but sometimes it doesn’t(Bullet gets lost, so I guess collision is made)
Any idea why?
Probably the bullet is getting destroyed before the collision registers with the enemy. This is a common problem when making collisions that destroy both participants. Instead of destroying them in the event, simply set a Boolean flag, and destroy them in Update.