Hello! I’ve been working on a first-person shooter game for a bit and have reached the point where I’m setting up the save/load system.
As enemy position is important in this game, I would like to be able to save the current ‘state’ (location, rotation) of all ‘Enemy’ actors in the level when you press the Save button, to be loaded when next you start from your save.
What is a good solution to this? I have a struct I will be using to store their relevant variables, but I am just not sure how to go about it.
Along with this, is there a simple way of storing your current level as a variable?
So what you will want to save is the transform of the enemies. That’s Location, Rotation, and Scale as one variable, just to make it easy.
So you’ll use GetAllActorsOfClass (or any other methods of getting them as an array) then on a ForEach loop, in the body of the loop use a “GetTransform” for the actor and add THAT to an array(or you can use a map). This will get the indexes to match 1:1 on both arrays.
Then when loading, when you spawn each member of the Enemy class, you’ll pull the index on your spawning ForEach loop, and for each Enemy Actor, SetTransform using that array you saved and the index from the spawning Enemy!
Saving current level as a variable would be based on the name of the level- check this thread for instructions on that.