Beginner Question: Tree Structure Error

Godot Version

4.4.1

Question

Hello all,
i am going crazy about an error i receive for 3 hours or so now and i can’t wrap my hear around it.
It looks simple but i am just learning and maybe i don’t see an essential part.
The bad boy is hidden here:

Once i only run print(“i am here”, name.self) and print_tree_pretty() i have following structure

┖╴RootController

I am here: RootController
┖╴@Node2D@2
┠╴menu
┃ ┖╴menu
┃ ┠╴ColorRect
┃ ┠╴ColorRect2
┃ ┖╴Button
┠╴class_choice
┃ ┖╴class_choice
┃ ┠╴ColorRect
┃ ┠╴warrior_select
┃ ┖╴rogue_select
┖╴game
┠╴CanvasLayer
┃ ┖╴ColorRect
┠╴hero
┃ ┠╴ColorRect
┃ ┠╴AnimationPlayer
┃ ┠╴character_attributes_label[0]
┃ ┠╴character_attributes_label[1]
┃ ┠╴character_attributes_label[2]
┃ ┠╴character_attributes_label[3]
┃ ┠╴character_attributes_label[4]
┃ ┠╴character_attributes_label[5]
┃ ┠╴attack_delay_Timer
┃ ┠╴Label
┃ ┖╴missed_info
┖╴enemy
┠╴ColorRect
┠╴AnimationPlayer
┠╴enemy_attributes_label[0]
┠╴enemy_attributes_label[1]
┠╴enemy_attributes_label[2]
┠╴enemy_attributes_label[3]
┠╴enemy_attributes_label[4]
┠╴enemy_attributes_label[5]
┠╴missed_info
┖╴attack_delay_Timer

I am here: @Node2D@2

How comes the paths can’t be found? What am i missing?

I think it has to do with the autoloading the scene. Have you tried without autoloading?

And are you autoloading your main scene as RootController and also use it as starting scene at the same time? At least the main scene is marked at start scene.

1 Like

You are autoloading a script.
This creates a new node instance without the children in your scene instance.

2 Likes

As others have said you are autoloading the script, this creates a new instance of the script with no children on the root as you can see in your prints here

Then you have the original object you are running, presumably as your main scene


If this is your main scene, then you do not want to autoload it. If this really should be a autoload then you should autoload the scene.tscn, not the script.gd.

If you need a reference to the current scene, and that’s why you wanted an autoload, then you can use get_tree().current_scene instead.

1 Like

Hello all,
thanks for your help in this matter! It was indeed the autoload. I disabled it and now it works as intended. Thanks a lot!!!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.