Problem connecting signals

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

I’m making a mobile Space Shooter game and I’m following a tip of GDQuest ( singleton). It was working well when I had to connect some touch screen buttons to the player functions like move_left move_right stop shoot.

When the player is ready it emits a signal called player_ready in and the Controls node (that owns the touch screen buttons) should receive this signal and connect the buttons signals to the player’s functions (note that the player is passed in the signal).

But it doesn’t work, I know why: when player emits the signal, controls isn’t in the tree yet…

How to fix that?

:bust_in_silhouette: Reply From: Sprowk

A scene does not load instantaneously. It is actually a tree that builts node by node when you instance it. Same applies for root scene (main). As you said yourself control is added after player into the tree.

  1. You could rearrange the nodes in the editor.
  2. If that is not an option you can also try adding a delay for player_ready