0 votes

I have a simple project, a KinematicBody2D player, some KinematicBody2D enemies, and a gun that shoots KinematicBody2D bullets. When the enemy runs out of HP, if falls in the opposite direction that the sprite is facing. This is fine, unless the player shoots the enemy in the back and kills it, when that happens the enemy falls over in towards the player. So what I'm asking is: is there a way for the enemy to get the direction it was hit from, and fall in that direction when it was killed? Any answers are appreciated, and thank you for reading this far.

asked May 30 in Projects by Jax1221 (17 points)

1 Answer

0 votes
Best answer

Presumably you're detecting the collision between the bullet and the enemy. When you do that, one of the pieces of information contained in the KinematicCollision2D object is the collision normal. You can use this to tell from which direction the collision occurred.

answered May 30 by kidscancode (17,132 points)
selected Jun 9 by Jax1221
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.