Hey guys
I have a blueprint with a box collision for the player to trigger an event. the trigger plays a level sequencer, changes transform of some objects, destroys some objects and spawns some AIs in the area. I’ve made a save game room for player to interact and save the game. I know of setting current transform (Variables) of objects in the world using GameMode and SaveGame but have no idea how to set current state of other things (Sequencer plays only once and also keeps state of some objects, destroying objects, spawning AIs, etc), pretty much reseting the Blueprint I have so when player dies and loads back, everything that the blueprint did be reset. How would you all go about implementing such advanced save game?!
Hey @Benyamin3000!
So yeah, you’re not joking. SaveGames can get really big, even though it’s typically just a collection of variables.
Typically what is done, is you’ll have multiple structs and save those structs as part of a SaveGame. When the game is saved, you would grab all this info, set it to the structs, and then write the save. So the structs might look like:
EnemiesStruct
Bool:Boss1->True (boss is dead, do not respawn)
Bool:Boss2->False(boss is not dead) //These boss bools would be checked on load-in to decide whether to spawn certain enemies. I recommend instead of placing directly in level, have them spawn using an invisible actor that can check the struct before spawning them//
PlayerStruct
Int:MaxHealth
Int:CurrentHealth
Int:MaxEnergy
Int:CurrentEnergy
Int:Money
And then for the player/level, on BeginPlay, you can set all of these values again directly from SaveGame ![]()
Yeah, it gets complicated. And there are many ways to go about it. This is just the way I learned it. Try to think about ways you can turn something INTO a variable, so it can be saved.
Oh interesting! I’d play around simple at first like saving variables to check if it should spawn an object or not after loading. I didn’t expect to get to this point but I love making game on UE because I’ve made it so that after saving, the trigger that player activates, it changes transform of many objects, spawns other triggers, plays sequencer and spawns 2 weapons, which are a lot actually. I’m thinking every single thing that player causes including: his stats, transform of all objects and AIs and whether should be spawned can be stored in struct to store in save game. and I’m thinking for do once triggers whether or not by loading the game they should be reset. Thanks for the idea!