Does the Player Controller Blueprints lose/reset variable data when you load a new level?

I was under the assumption that the player controller blueprint kept all variable information indefinitely.

My Issue: I have advanced and standard graphics settings in my settings widget. Standard just allows you to set Low/Med/High/Epic graphics and when you hit the advanced it opens another widget so you can instead change each graphics property individually. When I open the Advanced properties widget I want it to stay open even if you access the settings in the pause menu in the game. Problem was If I saved the variables in my settings widget blueprint they reset every time I opened the settings menu so I had to save my variables in the player controller blueprint and it all seemed to work great until I loaded the next level. After the level load it changed the state again of the having the advanced options are open or not. My actual settings are fine though because they are saved upon clicking the setting. One solution I thought of was saving the state of the menu like I do the settings… Any suggestions?

Lots of stuff gets lost when loading a new level…

Solution

Possibly the easiest way to ensure that certain variables persist for the duration of the game, regardless of level loading and unloading etcetera, is to use a BP based on GameInstance. You can set up any variables and functions you need there. It will be accessible from anywhere at any time, and doesn’t get destroyed until you quit the game entirely.

First create a new blueprint based on GameInstance:

https://dl.dropboxusercontent.com/u/2888286/GameInstance1.png

Then set it up in the Project Settings:

https://dl.dropboxusercontent.com/u/2888286/GameInstance2.png

And you can get a reference to it from any blueprint, to read/write variables or call functions etcetera:

https://dl.dropboxusercontent.com/u/2888286/GameInstance3.png

Setting up variables and functions in your new GameInstance BP works exactly the same as it does for any other blueprint. Hope this helps.

Yes. Use a SaveGame BP for that.

UE4 is made primarily for multiplayer shooters, so default gameplay code is more set for matches that reset each time (it not really resets, it just making new GameMode and PCs each game). If i’m not mistaken any UObject not tighted to UWorld is persistent, not just GameInstance.

I would still have to save the variables away with this so when you shut the game off and start back up it will keep the settings the same :frowning:

I am in the process of doing so. I already have the graphics settings saved, just need to save this.

I’m having a similar issue with this. I’m storing player data on the player controller this way I know client related data. I don’t know who’s client data is the from if I keep things in the game instance.
Is there a way to transfer player controller data to the new spawned player controller?