+1 vote

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 ;)

Godot version 3.3.2
in Engine by (19 points)

Are you using an area2d to check for the bullet or a different way?

1 Answer

0 votes

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()
by (430 points)
edited by
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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.