What is the best way to change scenes?, for a resident evil 2d styled game?

Godot Version

`4.2.2

Question

Hi, i just have a question, you see, i was searching on internet, ways to change the scenes in a game.

And i saw two ways, one using an autoload or singleton, and the other one, having a main scene, and add a child and remove it when is needed it (to save the data between the scenes).

But, im confused, i have two nodes, one that is the “manager” from the scenes, and another one that is the main menu of the game, where the game starts, how can i detect when i press the start button on the main menu scene, and remove the child in the “manager”, im doing this correctly?, or there is better way?

Use get_parent() to get the Manager and call the method you’re using to change scene or use groups, add the manager node to a group called “manager” and use get_tree().call_group("manager", "the_func_that_change_scene").

1 Like

You can simply use SceneTree.change_scene_to_packed() method to change your current scene to another.

You can call it as
get_root().change_scene_to_packed() from either of your Nodes in the scene.

1 Like

Got it, i will try that, thanks for the comment¡¡¡

Oh yeah i saw that, but a question, that will erase all the data inside of the scene right?, because you are changing the root node, and removing the old scene, i mean destroying it, right?

Correct, your data stored on the scene will be lost.
If you need to persist any data between the scene changes (like player stats for example), just put that data in the Autoload variables, or even consider saving it to a JSON file.

1 Like

(post deleted by author)

Got it, i will check that too, thanks for the comment, you helped me a lot¡¡¡