EXAMPLE:
You get 3 MapsâŚ
âWoodsâ, âMountainsâ, âDesertâ
Each has a unique Index
0, 1, 2
So, in your SaveGame Object, add an Integer <MapIndex>
Next, create a new Variable in your Savegame Object, a TRANSFORM. and called it <PlayerTransform>
Spawn the Savegame Object, and fill the two variables by saying: Player is in the Mountains, set Index to 1 and store the PlayerController.Transform into the Variables.
Now hit SaveGameToSlotâŚ
For loadingâŚ
Best is to create a new Variable in a custom GameInstance, a TRANSFORM again. Call it <PlayerTransform_Holder>.
Create a second Variable (bool) als call it <GameIsLoading> and set it to TRUE.
When doing LoadGameFromSlot, store the PlayerTransform into that GameInstance Variable (GetGameInstance â Cast to Custom Instance â Set PlayerTransform_Holder)
From the Loaded Slot, readout which Index the MapIndex has, use a SwitchOnInt Node for that, and LoadLevel the correct Map.
Now, open the Level BP of your Maps and in BeginPlay, get the bool GameIsLoading from GameInstance (GetGameInstance â Cast to Custom Instance â Get GameIsLoading) and Pin it to a Branch.
When Branch is TRUE:
Get the Transform Holder from the GameInstance (GetGameInstance â Cast to Custom Instance â Get PlayerTransform_Holder).
Now Update the PlayerController Transform, to the GameInstance oneâŚ
Set the GameisLoading bool to false.
Finally, lead the last Executer to the stuff, that gets calle dwhen the Branch is falseâŚ
When Branch is FALSE:
Do whatever you need to do⌠spawning Enemies, Collectibles, do Game mechanic StuffâŚetcâŚetcâŚ
DoneâŚ
Ps.:
You can save the Level Name into the Savegame, which prevents from renaming issues⌠You can get the Level Name with GetCurrentLevelName.
So, after loading, simply do a LoadLevel with the stored name, instead of Index/Switch.
And for question, why saving the Transform into GameInstance:
The GameInstance ist persistent. Values stored into it, persist upon loading level.