The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

I have nodes within a scene that I have referenced through onready vars. From my understanding using the onready keyword is effectively the same as initializing the variable within the _ready() function. To my knowledge, in the tree load in tree order then once all nodes are loaded the _ready() function of the main node in the tree runs. I do not understand how the nodes are not being found if this is the case given the screenshot here:

nodes not loading properly

in Engine by (18 points)

I assume the script in the screenshot is intended to be connected to the top-level GameHandler node, but are you sure that's the case? I see other nodes in the scene tree with attached scripts...

Assuming the above script is attached to the top-level node, are you sure it's not unintentionally attached to other node(s) too?

On the surface, I'd expect the code to work as you intend if the script is attached to the top-level node (and only to that node)...

The selected script is for GameHandler which is attached only to the GameHandler node. Originally I had Map as an instanced scene but I made it a whole part of the GameHandler trying to fix this.

Edit: Also I was originally using the "$" syntax to grab these nodes, which also in the editor finds these nodes. That's what bothers me the most is that it shows me it can see the nodes in the hierarchy but it isn't finding them at runtime.

Edit2: Even running the scene independently (Instead of the main scene) causes this behavior.

Is it possible to make the project available for review?

Here's a link to the zip.

Edit: There's probably some things not working as intended or not implemented yet because I was working through a couple of systems. This just doesn't make sense as to why the onready nodes aren't there at runtime.

That link leads to a 404 (page not found)

1 Answer

+1 vote

OK, so based on the above discussion and the linked project...

You do indeed have a 2nd copy of (incorrectly) linked to a node. That's what's causing the problem...

If you look at GameHandler_HUD --> ActionBarButton2, you'll see it's connected to the script. Looking at the other buttons, it looks like it is supposed to be connected to

by (22,674 points)

That's 100% it. I have no idea how that happened. Thanks. Is there a way to trace the node this script is running from? I'm newer to using Godot so I'm not very familiar.

Good question. I found it by adding the following to the _ready() function...


The results showed 2 things:

  • A node name was printed twice, indicating it was connected to 2 nodes
  • One node name was expected and one was not...
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.