How do i make a rigid body delete itself after colliding with a tilemap?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Arielrandal

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 _on_RigidBody2D_body_entered(body):
self.queue_free()

But it doesnt works, thanks for any help.

:bust_in_silhouette: Reply From: magicalogic

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.