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

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?

in Engine by (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

+2 votes
func on_Hook_body_entered(body):
    if body.is_in_group("surface"):
        #Whatever you need to do.

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.

by (617 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 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.