How do I make a RigidBody despawn using Area2D.

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

I am currently struggling at making my spawning mobs despawn when I hit them with my bullet which are Area2D.
The mobs are RigidBody .
My bullet despawn aswell as my player when they touch the mob but the mob doesnt and I dont know how to make that happen

Hi,
you should really show the code you have so we can see what you are doing and why is not working. Or even share the full project if you can. What is usually made is to connect the body_entered signal of the Area2D to a function called _on_RigidBody2D_body_entered and call body.queue_free() from there.

p7f | 2019-01-13 17:59

:bust_in_silhouette: Reply From: kidscancode

How are you removing the player and the bullet?

In the bullet Area2D, connect the body_entered() signal. Then you’ll have a function that gets a reference to the body:

func _on_Bullet_body_entered(body):
    body.queue_free()

I managed to do it myself now and I used body entered for my bullet aswell . But that wasnt my problem . Thank you anyway

Foxy | 2019-01-14 15:10