0 votes

I'm making a mobile Space Shooter game and I'm following a tip of GDQuest (Events.gd 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 Events.gd 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?

in Engine by (692 points)

1 Answer

+1 vote
Best answer

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
by (330 points)
selected by
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.