0 votes

enter image description here

Whenever i tried to run the game, it said attempt to call function ' add child' in base null instance on a null instance. The GridContainer node is already directly under the Calibration1 root node but somehow it doesn't detect it?

Godot version latest
in Engine by (23 points)

Why are you storing the node the script is on in a variable?

what do you mean

You have

onready var Game = get_node("/root/Calibration1")

Isn't Calibration1 the node that the script is on?

cardcalibration is the script for calibration1 control node. this calibration1 script is not attached to any node.

So it's a singleton? Singletons call their ready function before the other nodes so the node probably isn't ready yet

so how do i ready the nodes?

1 Answer

0 votes

Yield for the ready signal from Calibration1.

yield(get_node("/root/Calibration1"), "ready")
by (7,954 points)

after trying, i find that if i set my main scene as calibration1.tscn, it can run because then the tree of calibration1.tscn will appear in the root (remote).

but when i try to run the other scenes such as main menu, the root changes back to the tree of that particular scene and the the gridcontainer node cannot be found again because then it does not appear in the root (remote)

what way can i solve this? how do i have the tree of this scene always active in the root other than setting it as the main scene? or am i missing something?

You must make it an autoload singleton if you always want it to be in the SceneTree.

yeah, the singleton is there on the scenetree.

but currently the scenetree only have my main menu scene and the singleton active there. my calibration1 tree is not active, therefore the gridcontainer under the calibration1 control node cant be found and therefore throwing me the error.

I'm not referring to the Singleton you already have. If you want to have Calibration1 still in the SceneTree even when the main scene is the main menu, you will need to make Calibration1 a Singleton.

oohh, u mean the scene itself as a singleton.

I'm facing another problem whereby if I make calibration1.tscn a singleton, the program can run but the things that suppose to load inside calibration1 is gone.

Right now the things inside calibration1.tscn can only run if I play it from calibration1.tscn but it cant be set a singleton otherwise the things inside wont load apparently.

So basically if I make calibration1.tscn a singleton as you mentioned, the project can run from the main menu but then when it arrives at calibration1.tscn the things inside wont load. If I don't make calibration1.tscn a singleton, the things inside can load only when played directly from the scene itself since playing the whole project from the main menu would throw the node not find error again.

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.