0 votes

I tried to make a script that detects the collided object groups and then if the collided object is in the Wall group it's queue_free() but i wasn't success on that
I also tried to make it in visual script but that's another story

my GDscript function is:

func _on_Area_body_entered(body):
    if is_in_group("Wall"):
        queue_free()

what could have gone wrong?

in Engine by (66 points)

1 Answer

+1 vote
Best answer
func _on_Area_body_entered(body):
    if is_in_group("Wall"):
        queue_free()

Here, is_in_group("Wall") will check if the node holding this script is inside the Wall group. It does not use the body parameter at all.

But if you change it like this:

func _on_Area_body_entered(body):
    if body.is_in_group("Wall"):
        queue_free()

This will check if the colliding body is inside the Wall group. Choose the one you need.

by (27,277 points)
selected by

It worked!!
Thank you so much!

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.

Categories