+1 vote

I have this code here:

   for c in self.get_children():
        if self.get_children().size() > 0:
            c.connect("body_entered", self,  "nextDialogue")

what I would like to know, is that if and how could I take the body_entered signal, and get the node of that area2d that was entered. I don't really need to know the body that entered it, just the area2d.

Bonus points: Is there a better way to trigger an event? each of my area2Ds have a string on them that lets me assign which event to start when the player enters that area. I'd love any feedback and/or a better idea!

Godot version 3.2.3 stable official
in Engine by (35 points)

I suppose something else if its possible, is if I can modify the existing body_entered signal so that I can also pass itself through code. I'd really like to be able to not spend a lot of time connecting code, or doing something complicated.

1 Answer

0 votes
Best answer

so i didn't expect this to work, but i simply did this in the connect statment:

c.connect("body_entered", self,  "nextDialogue", [c], CONNECT_ONESHOT)

and in my function nextDialogue():

func nextDialogue(body, c):
    print(c.name)
by (35 points)
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.