change_scene_to with PackedScene fails on Windows

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By l.riehl

I’ve implemented a level transition handler that takes an export var PackedScene in the editor and calls a singleton to initiate a level transition:

LevelTrigger.gd

extends Area2D

export var next_scene : PackedScene

func _on_LevelTrigger_body_entered(body):
	SceneChanger.change_scene(next_scene)

SceneChanger.gd

extends CanvasLayer

onready var transitionPlayer = $AnimationPlayer

func change_scene(next_scene : PackedScene):
	transitionPlayer.play("TransitionOut")
	yield(transitionPlayer, "animation_finished")
	assert(get_tree().change_scene_to( next_scene) == OK)
	transitionPlayer.play("TransitionIn")
	yield(transitionPlayer, "animation_finished")
(...)

Then, in the editor, I’ve assigned it the scene I wish to load, in this case a World.tscn. When testing locally on Mac, both in the editor and in an exported .dmg, entering the trigger zone initiates the level transition with the animation, and then loads the next area. All working as intended.

However, I’ve exported a windows .zip for a friend to be able to test on Windows (with a .exe and a .pkg), and she showed me that entering the transition area triggers the animation, but the load fails and she remains in the same scene. I don’t have access to a PC right now and can’t test for myself.

I have a suspicion that this probably has to do with the way I’ve exported my project. I haven’t touched any settings, leaving everything as default and ensuring that Resources > Export Mode > Export all resources in the project is enabled. That said, is it possible that this method of changing scenes isn’t working in Windows do to another reason? Naming conventions, file locations, etc?

Thanks!

:bust_in_silhouette: Reply From: Calinou

That said, is it possible that this method of changing scenes isn’t working in Windows do to another reason? Naming conventions, file locations, etc?

On Windows, file names aren’t case-sensitive by default but they will be case-sensitive once the project is exported. This is because the virtual PCK filesystem is always case-sensitive.

If you’re developing a project on Windows 10, it’s recommended to make the project folder case-sensitive to avoid surprises when exporting the project.

So everything from .tscn files to scripts and folders should be using snake_case to make sure it works across all systems then? Thanks, I’ll give it a shot!

l.riehl | 2020-07-05 21:33