So, with my limited coding knowledge, I’ve been having a hard time figuring out how to do scene changes. I want to be able to change the scene while keeping player information such as health, current ship, etc. Something simple like how a metroidvania does their room changes.
Right now I just have a simple way to change the scene, but I have no idea how to make it so I enter a scene within a certain area and with saved player stats.
Well there’s a lot there TBH. This script is just on each level, and what I use to load each level. The level loading script gets passed the level, and then it calls start(), passing in an incoming_player which is assumed to be some sort of Node, and the name of a Node in the level that is the name of a spawn_point placed in the map.
If the incoming_player is null it’s a new game, and I load a default player instance.
If the spawn_point is null, it is assumed that this is a new game, and the starting level has a default starting point. It can be a Marker2D or Marker3D. I typically use an Area2D or Area3D with a CollisionShape2D or CollisionShape3D just so I can see where it is when I’m level building.
I turn the player’s _physics_process() function off, then back on so it doesn’t move around on the map until it’s placed correctly.
If the level has music I play it.
Then I load the saved game. This restores anything in both the level and the player such as health, items, pickups on the map, etc.
Last thing I do is make sure the player is visible.
If you want to see all the pieces working together, I have a game template that you can see an example of it working.
Someone else might have something simpler to show you. This is just what I’ve got.