contacting a node

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By snk


So, in order to contact a node I have 2 main ways :

  • Traversing the scene tree using get_node / get_parent
  • Using signals

But sometimes it’s hard to figure when using one is more appropriate than the other one.

Any clues ?


:bust_in_silhouette: Reply From: coffeeDragon

I personaly try to use singals for events, like player died.
Things that you would otherwies have to check in a _process(delta) function.
Which would make the overall game a lot slower and harder to read.

I would suggest to you, to try to use signals for most of the communication in the direction children → parent/s or whenever something changes the overall gamestate. That way you decouple your components. Basicly avoid calling get_parent or $"..". see:

small notes:
get_node() => $path or $“path”
I’ve read on that “forum” that caching get_node() is better then using it mulitpletimes, see: