For 2D adventure game, do you switch scenes from within each scene or from a singleton scene switcher script?

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

Does anyone have experience building point and click adventure games with many different scenes? If so, how do you manage scene switching?

Say you have 500 full scenes, (actual playable game scenes with different backgrounds, puzzles, etc.), how do you manage them all?

If I click on the left or right side of the screen, I want to be redirected to a completely different scene.

Should the currently active scene load a new scene by name using something like "(get_tree().change_scene(“res://path/to/scene.tscn”), or should all scene switching be managed in a singleton script, like “SceneManager.goto_scene((“res://path/to/scene.tscn”)”?

I know it can be done either way, I’m looking for an experienced developer who can explain which method would be the best approach, and why.


:bust_in_silhouette: Reply From: Oen44

Create array that contains all scenes paths, then have variable and assign number based on scene index and if you want to go to next scene then increase that value, get scene path from array using that variable as index and load it. You can create SceneManager as a helper, create function like load_next_scene or load_previous_scene.

If you don’t care about scene names then name every scene like Scene_X where X is the number, so it’s going to be Scene_1 to Scene_500. With that in mind, you don’t need array and use "res://path/to/Scene_" + str(sceneIndex) + ".tscn".

Using singletons is a good idea if you are going to use scene loading with several scripts. If only one script is going to load scenes then there is no need to use separated script.

:bust_in_silhouette: Reply From: Jams

For now I’ll try using x,y to plot current scene’s location on a grid. Navigation from scene to scene might be done by incrementing or decrementing a row or column. This should allow for up, down, left, right scene switching.