+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!

asked Mar 1, 2016 in Engine by ugly_cat (165 points)
edited Mar 1, 2016 by Akien
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

answered Mar 1, 2016 by alket (149 points)
edited Mar 1, 2016 by Akien
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 How to use this Q&A? before posting your first questions.