Godot Version
4.4 stable
Question
I’m seeing this error in my export’s console. It doesn’t seem to affect gameplay as far as I can tell, but since it’s a RED ERROR I’m concerned
ERROR: Condition “p_scene && p_scene->get_parent() != root” is true.
Src: godot/scene/main/scene_tree.cpp at 1753893c60ac309c21a77201725fa2820caf7f1e · godotengine/godot · GitHub
Could come from here, root is the main window (I think), does this only happen when you exit? root is deleted when you exit, changing the scene is not possible.
This could also happen at startup.
1 Like
Thanks Alex—do you know what set_current_scene does? Is it not finding root?
Looks like it errors every time I change levels, after I’ve loaded the scene. I remove the last one, then I add_child. get_tree().set_deferred might trigger this error? Root never leaves. Shouldn’t, anyway
It seems to be serving up levels as expected, and I’ve double checked the tree looks right. Hm…why the error?
autoload-demo: godot-demo-projects/loading/autoload/global.gd at master · godotengine/godot-demo-projects · GitHub
# Set it as the current scene, only after it has been added to the tree
get_tree().current_scene = instanced_scene
I think this is how the C++ function is executed, does this demo help you? Or do you already have something similar and the errors are still displayed?
1 Like
I wasn’t even aware of change_scene_to_file() (and should look into it!)
Mine is more complex with transitions and so on, but it swaps out grandchildren, so maybe that helps explain the error. Now I’m wondering if I’m using something other than change_scene_to_file() that still hits set_current_scene(), which expects to be working directly under the root. Not sure why everything works fine, then…
<time passes>
Aha! I had get_tree().set_deferred(“current_scene”, content). It’s undesirable in my case, since I’m swapping at the grandchild level. It shouldn’t have even been there since my my level has already swapped. So, it could error, but everything looked right anyway.
Thanks for the help Alex 
1 Like
C++ Macro ERR_FAIL_COND
also terminated the function prematurely, so that the variable current_scene
is not set
ERR_FAIL_COND(p_scene && p_scene->get_parent() != root);
current_scene = p_scene;
#define ERR_FAIL_COND(m_cond) \
if (unlikely(m_cond)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true."); \
return; \
} else \
((void)0)
1 Like