Trying to make an enemy death in Godot

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By FlamingleGames

Hey everyone!

I’ve been trying to make an enemy death occur when a bullet shoots at the enemy. Basically, I’ve used a prefab for shooting bullets, so there can be an infinite amount of bullets to be shot.

I’ve been trying all day, but whenever a bullet hits the enemy, nothing happens at all. So, take a look at my code and let me know where/if I’ve gone wrong, in the screenshots at the bottom of this post.

For additional context, the “dead.gd”, and the “die” animation is there, because I’m using an area 2D for both the player death, as well as the bullet shot. (I really hope this makes sense!)

When both the player collides with the enemy (aka, the “Karen”), the game over screen appears. This is scene on line 16 of dead.gd.

I’ve done this on line 19, but the same result does not happen. If you look at line 5, the “Bullet” variable is made for the prefab.

Overall, what I’m trying to do, is make the enemy play an animation, when it is hit by the bullet. I’m not sure if this isn’t working due to the bullet being a prefab, or something else. Any tips, fixes, or alternate code or tutorials is much appreciated. Thank you so much!

PHOTO DESC ONE - ![“Dead” script, holds enemy death from bullet, and player collision/game over screen as well][1]

PHOTO DESC TWO - ![Code used for bullet][2]

PHOTO DESC THREE- ![This is the bullet itself][3]

PHOTO DESC FOUR - ![And here is my enemy, who in this case is a Karen][4]

PHOTO ONE - [1]: https://preview.redd.it/opame5y39i671.png?width=1920&format=png&auto=webp&s=84bece263589e0f36bca844dd1ff80ecf55365ab

PHOTO TWO - [2]: https://preview.redd.it/5qm9qxx39i671.png?width=1920&format=png&auto=webp&s=46dd12bc159b0f435cbcae7197be3db1c59bc58a

PHOTO THREE- [3]: https://preview.redd.it/l773mxx39i671.png?width=1920&format=png&auto=webp&s=e290f7c550f3fa191a97155b43741188b0a9c548
PHOTO FOUR- [4]: https://preview.redd.it/kowtp8y39i671.png?width=1920&format=png&auto=webp&s=9a01753eaf98d2b9a8231dd63460416d57a79a09

:bust_in_silhouette: Reply From: exuin

Not sure if someone on Reddit has answered this for you already, but “Karen” is not a body, it’s an Area. So you need to connect the area_entered signal instead.