How to transfer information between maps/levels

So I am working on a life/farming simulation game. How do I transfer things such as time keeping, light position and settings, and other such cross level information across levels. For example if in one map the time is 12:00pm how do I make sure its 12:00pm in the next level the player goes to and if the area is outside to also take with it the position of the sun and all that jazz with it. Do I use a game instance? Do I partially save the game to apply those variables? I am just confused on what exactly I should be looking into.

Both. While the Game Instance approach would work, it’s a good idea to save that information to disk. You will need to save the game eventually anyway, right?

1 Like

Okay so both, I appreciate it. Ill just move the saving game part of my GDD up then and figure it out now along with the game instance.

Game Instance would be the way to go if you want to keep data alive while the game is active. Nothing more, nothing less. When the game loads up on then next map, read your Gameinstance’s saved data to set the current data.

In your case with the clock time, when the player enters a level change trigger or performs a level change in some other way, save the current clock time as a float (or whatever datatype you use for your clock value) to your GameInstance. When the game starts on the new level, such as in GameMode’s BeginPlay, look up your GameInstance, read the current clock time and apply it to your game clock.

Saving to disk should only be done if you really want/need to, such as for auto-save purposes. If you want to have an auto-save with every map change, put your current state in the game instance, so you have a valid state for the map change, and then, after having applied everything to the game instance, save whatever the game instance has as information.

On the other hand, if you don’t want to auto-save with every map change, just use the GameInstance for temporarily saving information and don’t do any saving to disk.