+1 vote

So I have a World instancing a Player, and the Player has states as nodes.

What I want is to "raise" a signal emited by one of the states node as if it was emited by the Player so the World only needs to interact with the Player and not its nodes.

I though just doing another emit_signal() because I don't know if there's a more elegant way to proceed.

in Engine by (13 points)

1 Answer

0 votes

It is possible to add a signal in code using the Object.addusersignal() function. You could have the child nodes add signals to the parent node.

I have a project starter repository on github. It has something I call a Signal Manager, which allows you to register a publisher and subcribers of signals. (A publisher would be the object emitting the signal, while the subscriber is the object with a method connected to that signal.) If you use the Signal Manager, you could subscribe to the child's signal in the World and register the children as publishers. Please see the readme on the github page for examples. The link the repository is https://github.com/jhlothamer/godot_project_starter.

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