0 votes

The onbody_entered signal seems to work backwards to how I need it. I have a grappling hook (Rigid body 2D) that needs to know the group of the thing it collides with, but for some reason the following code returns the group of the hook itself.

func onHookbodyentered(body):
if body.isingroup("surface"):
do stuff
queuefree()
else:
queue
free()

I've struggled with signals since starting with godot. Is there a smarter way to detect when the hook collides with something and then get the group of that something?

asked Mar 11 in Engine by demon3o5z (17 points)

what do you mean by "returns the group of the hook itself"? i don't see anything in that block of code that would return a group name.

I should just close this down. It now works. I could not tell you what I changed.

1 Answer

0 votes
func on_Hook_body_entered(body):
    if body.is_in_group("surface"):
        #Whatever you need to do.
        queuefree()
    else:
        queuefree()

Their could be anything wrong but lets start.

1.Is the collision shape or the parent of the collision shape in the group?
--If so then you may need to do

if body.get_parent().is_in_group("surface"):

2. If it is a tilemap then make sure the tilemap is in a group.
--if it's not then nothing will make it work except adding it to a group.

if none of these work or are the problem then tell me.

answered Mar 12 by Merlin1846 (172 points)

Thanks for the response, but it works now. And I could not tell you what I changed.

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.