+3 votes

Is there anyway to control the order in which code in disparate script files will run in the _ready() function? Basically I'm using get_node() to grab a node which is instanced via another node. This throws an error because it wasn't able to find the node because it wasn't instanced yet!

in Engine by (173 points)
edited by
Please use back quotes to mark code, that will avoid _ to be interpreted as an italic marker.
e.g. ``_ready()``

1 Answer

+5 votes
Best answer

You can use: onready var node = get_node(), before anything else, outside of all functions

by (150 points)
edited 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.