What state-related objects will persist between levels?

I spent a lot of time trying to find this out but couldn’t find an answer for everything I’m interested in.

Some objects are destroyed between level loads, and some aren’t. The documentation gives some hints but I can’t find any info on some objects. Does anyone know which of these persist across level changes? (I’m filling in the ones I think I know)

GameInstance: Yes
GameMode: No (instantiated with Level BP)
GameState: No (instantiated with GameMode)
PlayerController: ???
PlayerState: ???
AIController: ???
Actors/Pawns/Characters/etc.: No

I’m primarily interested in single-player…if the answer is “No” to everything but the GameInstance, does that mean that’s the only place to store “permanent” info, like the player’s name, NPC attributes such as names/experience levels/strength, dexterity, constitution, quest progression data, etc.? So the GameInstance class would have to handle keep track of all of that data?

3 Likes

Yes the GameInstance is the only thing that persists when a new level is loaded. You can however choose to use level streaming and not actually change level but just load and unload a sub level although it might not be worth the trouble since then you have to reset things manually.

A more viable option is to use Save Game Objects so the state is written to disk and can be recovered at any time even if the game is closed and reopened.

3 Likes