I’m making some classes that feel like they should belong as part of AGameState. E.g, data about which in-game factions love or hate which other factions. It’s really global data about the state of the game, which will have a default value when the game begins, and then update as the game progresses. I have some questions related to this:
When a new game starts, I want to initialize this game state data from master data that feels like it should belong in AGameMode. However, if I do this in BeginPlay(), that will happen too often, won’t it? E.g, if the human saves the game to disk, then loads the game later, won’t BeginPlay() be called again? I wouldn’t want to re-initialize the gamestate data then; it should use the last data that was serialized in the save game. What I’m really after is something like BeginGame(), that will happen once and only once per game, not per game play session. I’m not sure about it, but it seems like BeginPlay would happen for each save/load cycle. What is the recommended way to do per-game initialization like this?
I want to be able to edit the “game mode” type defaults in the editor, but AFAIK you can’t do so right now. E.g, if I add a new UPROPERTY(EditAnywhere) in AGameMode, it isn’t exposed in the editor. I can set the data up manually in C++ code, but then I’ll have to copy the data into the game state on match start. On top of that, if there are actors that hold pointers to this data, I’ll have to find them all and update their pointers to point to the AGameState data when the match starts, which seems awkward.
I feel like I am missing something important about how this is designed to work.