• Godot Help
  • Godot 4: change_scene_to_file() not working in executables

Hello,
I'm trying out Godot 4 and I noticed something strange. According to the documentation, change_scene() was replaced by change_scene_to_file().

So, when I do
get_tree().change_scene_to_file("res://path/to/file.tscn")
it works fine, when I run the project. However, when export it to a Windows Executable, suddenly it no longer works. The inputs are recognized, but it simply doesn't change scenes.

What am I doing wrong? What would be proper way to do it?

  • I haven't used Godot 4.0 that much, but it seems like it would work. Can you export the Windows executable with debugging enabled and launch the game through the Windows terminal/command-line/console (cmd or Powershell)? This should make it where it prints debug info and that may help indicate what is going on. It might be that it would report an error when it tries to change the scene.

I haven't used Godot 4.0 that much, but it seems like it would work. Can you export the Windows executable with debugging enabled and launch the game through the Windows terminal/command-line/console (cmd or Powershell)? This should make it where it prints debug info and that may help indicate what is going on. It might be that it would report an error when it tries to change the scene.

    The res folder only contains exported assets. You probably have to check the export settings and make sure all the dynamically loaded (by path) assets are whitelisted.

    TwistedTwigleg Should have done that in the first place, thanks for the suggestion.

    Turns out there was a reference in there to a file I had deleted earlier. For some reason it still tried to reference that file, although I don't know why. I put a file with the same name back in, it worked then. Strange that this didn't cause any issues when running it from the editor. No errors or warnings.

      Irolan Strange that this didn't cause any issues when running it from the editor. No errors or warnings.

      Strange, but glad that it’s fixed at least! Maybe the editor had a copy in RAM or the .import folder or something

        Watch out for the file name. It's case sensitive and also I think has problems with non-Latin characters or special symbols.

        The sad part I think is that the editor is NOT case sensitive but exports are. Seems like an oversight, but that's probably the issue.

          TwistedTwigleg Yes, the .import file was still there, even though the original file wasn't. Guess that's what confused it.

          cybereality That is excellent information, thank you. I will keep it in mind. Not the issue in this case, but definitely something that could cause problems in the future.