Topic was automatically imported from the old Question2Answer platform.
Asked By
grafyan
I have 2 kinematic 2d bodies. One for bullet and one called Zombie. I want to know when the zombie is colliding with the bullet so i can reduce its life but i can’t find function to get the name of colliding body
I ll apreciate if u help me
Are you using an area2d to check for the bullet or a different way?
you can use an area node attached to the bullet node and connect it’s signal when a physics body enters it, the signal’s function has a body parameter that is the reference to your zombie or any colliding physics body, then you can access a function inside the zombie script:
func _on_myBulletArea_body_entered(body):
if body.is_in_group("zombies"):
body.reduce_health()