0 votes

Hello, im new to coding and just started with godot, ive been following some tutorials and i made a tilemap with a static body and collision shape, a sprite that can move around and shoot a bullet that is a rigid body with a sprite and a collision shape (all in 2d) and i want to make the bullet dissapear or delete itself when colliding with the tilemap, i tryed using:
extends RigidBody2D

func onRigidBody2Dbodyentered(body):

But it doesnt works, thanks for any help.

Godot version 3.3.2
in Engine by (37 points)

1 Answer

+1 vote

You have to connect the body_entered signal to that handling method first.
At the ready method, add this line.

connect("body_entered",self, "on_RigidBody2D_body_entered")

Now your method should work and the bullet should disappear when it collides with other physics bodies.

by (1,127 points)
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 Frequently asked questions and 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 [email protected] with your username.