Godot Version
v4.5.1
Question
Hey I saw some discussion about this topic in some people said it’s just a bug and there is no way to fix and others show some solution but they a) don’t work for me b) I’m probably too stupid to understand them.
My main idea is to use class script to show and hide other scene of same class on button click. So I do
@export new_scene : PackedScene
yet it’s always null no matter which scene of my project I will pick from this scene
I tried so many thanks, I created new project and it’s working there, it kinda work on my 2 main scene but only if I use get.tree()_change_scene_to_file(new_scene) but then new_scene need to be string of path to this scene.
Yet, here where I need it it doesn’t work (Also I still have no idea what to do next, how to access node from this exported scene to use progressbar.hide() and .show() )
Here is ss, the weirdest thing is error tell me this value is null yet it show object in inspector…
idk if it’s important but here is ss of all my files
Thanks for you time to think about my problem ^^
The error means that get_tree() returned null, not that new_scene1 is null.
Since the call to get_tree() two lines above appears to be working, something must have happened in that action group call that plucked the node out of the scene tree.
2 Likes
Thanks I delate everything in this on_button_button_down() function
now program doesn’t give any errors yet it also don’t load this scene. Nothing change after pressing button. But now when I use it as var I can see scene commands (after dot, it didn’t happend before). but no matter what I use (get_child, get_node) it’s always gives me null value
Why?
Of course if doesn’t load the scene if you deleted the call that’s supposed to load it.
Oh I mean I delate everything belowe it. It’s still working as button down, I add print there and it’s saying scene ID but get_tree().change_scene_on_preload(new_scene1) don’t do anything and it’s just belowe working print
Try calling get_tree() only once at the start of the callback and then use the reference it returned for the subsequent calls. Or use Engine.get_main_loop() instead.
This may prevent the crash but note that the whole situation indicates that there may be some deeper problems with how you organized your scene and code.
1 Like