Download

SaveGame vs GameInstance

Hello,

I do not understand the sense of GameInstance.

SaveGame save things between launches of the game.
GameInstance between level switching.

So SaveGame can do everything, what GameInstance can do, right?. Because you can load the data every time. Is there a reason to use GameInstance?

Greetings

You dont have to use GameInstance at all, if you want to you can save data between levels with SaveGames.
But why would you do it if you dont need it? Its like wanting to open the door but instead you take a rock and throw it in your window to get in, you can do it but as long as you have the keys you dont need it.

Edit: https://wiki.unrealengine.com/Game_Instance,_Custom_Game_Instance_For_Inter-Level_Persistent_Data_Storage

i’m not an expert but as far as i know, save game will contain all the data of the game that have to be saved but moving from level to an other doesn’t require restoring all the data (you may want to transfer only player stats: health,ammo count, things like this)
so as far as i can tell the difference is about the game resource optimisation3

Because I use both and I am considering using just one method. So if I would change things to save, I need only modify one thing.

Why your rock metaphore? Are SaveGames slower?

Like HAMZAest10 said.
Its writing down informations and putting them in a locker, go back to the locker search for the informations and give it to someone, or you could just give them away.
You can do it in case you need them to be saved.

The main difference concerns ownership and lifetime.

Game instance is automatically created and exists across levels for lifetime of game.

Save game must be explicitly created and is owned by something (e.g game instance)

Both are tools at your disposal, they are not redundant and serve different purposes…

I use game instance as a container for all my “global variables” and things that are otherwise difficult to share between BPs and simple data to retain between level loads. It just makes things easier.