Hi, I’m working on default first person template and I was wondering where to store data such as inventory that can be retrieved even after character has died and respawned. At moment, all character specific data is inside my character blueprint. But before continuing any further, I would like to know ideal workflow related to storing important persistent variables. And I do not need to move this data across multiple levels. I just need to store data from level start till level end.
Any important variables that are involved with player should be Done in player BP probably. That way you create your save game blueprint you can pull it in and out of you character BP easily and save all of those variables to SAVED versions of this variables in ur save game bp. And then load opposite way when needed.
Thanks, I don’t have save game requirement. I only need to store upon death. So I guess I can do a similar thing with player controller instead. When I spawn and possess a new character, I can take necessary values from controller and put in character BP.
You could create a new Inventory class (Actor) , and have inventory data there.
I like to keep most of my game related stuff inside GameMode ,
there is only one GameMode running so it can be used to keep references to all other important classes and it’s contents, a simple solution is to keep game play stuff right inside GameMode , or as I said you create another class to keep things neat.
PlayerState is a good place to put things like score, player details, and other data you want to remain saved. This also allows information to be replicated to other clients, a good thing if you start messing with multiplayer. You can create a custom PlayerState by creating a new Blueprint and searching for that class. Then you can set that PlayerState as your default in GameMode. More information on setting that up can be found here:
Hope that helps!