hello! I’ve been stuck for a month already trying to save current characters while travel to other map. so. basically i have map where two characters are already correctly assigned for two different player controllers. i need to travel to another map. how can i properly «remember» which controller corresponds to which pawn and possess placed characters on existing map?
Set your variables in the game instance and call them from your player controller and set them on your character when you arrive in the new level. The player controller will reset to defaults anytime you travel, the level restarts, or a player is respawned and possessed.
The game instance will remember any variable settings as long as you have the game application running and you can retrieve them anywhere you have a properly instantiated and active player controller. In other words, try not to call any of these events until the player controllers are good and loaded into the level.
You can save variables on the player controller or character BP too if they are throw away variables, meaning if you just want them while a pawn is in use and when the actor is destroyed or possessed somewhere else they’ll just revert to the defaults. Like ammo. You start off with 300 ammo, fire off 250 rounds, your character is destroyed, when you respawn a new character you come back with 300 ammo.
If you save it on the game instance and call that variable from there and start off with 300 ammo, fire off 250 and respawn, you will have only the remaining 50 ammo, until you make any changes to the variables in the game instance.
The game instance is really the only reliable place to load in save games and settings as well. This is perfectly useful for turning on the game, setting graphics settings or some kind of preferences in variables using save game to save them and the when the game loads for each new play session if the save game exists you can then set those save game variables on the game instance each time. The player can then come back and continue making progress each time they play at a later time. These save games can be called at any point on any level and if set on the game instance at the right time and place it’ll be as if nothing changes as you progress in game play.