Saving a character, not based on level.

Heyo all,

Small question regarding saving data between multiple worlds.

I have a main parent blueprint for a spaceship. There are several child blueprints that contain different meshes for spaceships but keeping similar traits to the parent (With some changes)
The player can buy a new ship at a port. This replaces the current player pawn with a new one that is then possessed (One of the child BPs)

I have stats such as credits and stuff of that nature saved in a game instance so that data travels fine between levels. However, how would I go about saving what Pawn the player is controlling per levels? So if I buy a ship in one level, and move to a different level, it wont start that different level as the default ship?

One idea I did have was to simply replace the mesh when buying a new ship, not the whole BP. However since other ships have different weapons, storage space, etc etc, using different BPs seemed easier for that, up until this point.

Hope I explained alright, let me know if you have any solutions to this. I’m not new to BP’s but this small issue I cant seem to figure out.

-Alexander

I believe you would have to save the information within either the game mode or the game instance, then pull that information when your player spawns in the level.

Hmm okay, is this the only way to have that information saved. To my knowledge you could only store variables in the game instance. as for saving in the game mode, this is something I’ve not done.

Here is what I tried out quickly, added a variable and changed it to a Pawn Class Reference which allows me to choose what Pawn it should be. This is in the Game Instance.

Hopefully this helps you out.

If I’m choosing what Pawn it should be, this can only select one Pawn though, right? Even though I have multiple ships the player can own. So I would need to update that variable based on what ship the player has bought?

You could turn the variable into an array of ships the player has purchased and then select the one you want to spawn out of that list.

Alrighty, let me give it a go and play around, see what I can do.

Okay, so. I have it working.

I did somewhat follow as you said and used a class reference to set the ship that should spawn in the new world.

When I player buys a new ship, I update and set what the new ‘CurrentShip’ class should be. On loading the new level, it checks which ship is set as the ‘CurrentShip’ and spawns it to possess it in the new level. Working great.

If the player buys a new ship, it will know what one they bought, and spawn the correct ship accordingly. I didnt use an array, however, it is likely that I may update the system to do this in the future.

Thanks.

Sweet, glad you got it working.