Variables in GameInstance BP not persisting across level change

Hello, I’m still fairly new to Unreal but have been able to find a lot of good resources online so far that have been helpful, but there is this issue I’m having that I can’t seem to find any resource on.

I understand that the GameInstance BP is meant to persist through level changes, but the actors that it spawns and keeps a variable reference of do not. I am trying to create some singleton behavior BP actors to help me manage certain aspects of my game.

I have a BP Actor named NetworkManager which manages a network connection to a custom networking solution I have, and I have another called PlayerManager which keeps data on the player such as the players name, profile Id, etc. In my GameInstance BP I am spawning these manager actors and then setting a variable in GameInstance to these spawned instances of those managers, but whenever I open a new level these spawned actors become “invalid” or null.

Is there any way I can have this singleton BP design work as I intend it to? I want my GameInstance to keep a reference to each of these managers, and for these managers to persist. I come from a Unity / C# background, C++ is still quite new to me but I’m open to learning more about that.

I understand I could just take all the content of my NetworkManager BP and my PlayerManager and just put it all in the GameInstance BP, I think that would definitely work but it feels messy, I’d like it if I can have it organized better and have the functions and variables belong to a blueprint that makes more sense as the container for those, rather than them being all over the place in my GameInstance BP.

It is true that the GI lives through level changes, but stuff you put IN the levels will not, because, er, you’re changing the level :slight_smile:

If you want the behavior you’re describing, you need to get into level streaming.

There, all spawned actors live in the persistent level, and you load and unload other levels around them, no problem.

1 Like

Alternatively, use Objects instead of Actors. Those are not bound to the level.

2 Likes

Thank you for these suggestions I will definitely look into these options! :slight_smile: