0 votes

When i kill my enemy the area2d and sprite queuefree but not my collision, let you know my detection code is on a different script (on my area2d) and movement in another (on my rigid body) my rigid body is the parent and the area2d is a child how can i make the child queuefree the parent

in Engine by (399 points)

1 Answer

+1 vote

Adding some screenshot would make it easier for you to explain and others to understand what you are trying to do.

If I understand correctly, your node tree looks something like this

Node Tree

And your code something like this

extends Area2D

func _on_body_enter(body):
    queue_free()

If so, then you probably just want to do

extends Area2D

func _on_body_enter(body):
    get_parent().queue_free()
by (84 points)

Or, if the parent has a script, connect the Area2D signal to the parent directly.

how do i do that

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.