|Topic was automatically imported from the old Question2Answer platform.
My current setup looks like this: I have one KinematicBody2D “Player” and multiple other KinematicBody2Ds “Enemy”. Both the player and the enemies can shoot “Bullets”, which are each an Area2D. The game area consists of a TileMap with solid wall tiles.
Right now, all the bullet does is that it destroys itself once it hits a body with body_enter. But now I want the player and enemies to receive damage if they are hit by a bullet, but I am seriously stuck. I’ve tried multiple different ways but none have worked.
- Use get_slide_collision() on my enemies to detect when they have hit a bullet. This doesn’t work since this only detects collisions with bodies, not areas
- Send out a “hit” signal from a bullet when it hits the player or the enemy. But this would mean that I would need to connect every bullets “hit” signal with every enemy so they can detect it, which seems horribly impractical
- Turn my bullets into RigidBody2Ds so I can use get_slide_collision() on my enemies. But then the bullet can’t detect when it hit’s a wall, since a wall is not a RigidBody2D.
It seems like such a simple thing but I really can’t wrap my head around this, so I could really use some help here.