Godot Version
Godot version 4.3
Question
Is this situation the correct use of Signals in Godot? (ie, best practice?)
The goal with this pseudo code is when a new level loads a number of other nodes needs to do things. One is the player needs to be set to the starting point of the level. (each level can have different coordinates for the player starting point)
- Load a new level via gdscript. (add_child, etc…)
- Level node (on _ready()) emits custom signal “level_loaded” and passes a reference to itself as a parameter.
- Player node (on _ready() ) has connected to the signal “level_loaded” to call “_level_loaded” on player.gd.
- Player node moves itself to the start position in the level. (ie, using data accessible via the passed parameter)
Or should I use a Callable?
I’ve read the docs on Signals, and it’s explicit about being “past tense” and “not intended to start actions”. Is that what this situation is from a Godot perspective?
Is the better option for the level node to get a reference to the player node and directly call a function on the player node? This seems more tightly coupled, which is also not best practices…
Thanks for any help on this!