Preserving actors between streaming levels?


Hopefully someone can tell me the easy way to do this, as I am busy building far too a complicated a solution in my head.

I have a persistent level which manages a bunch of streaming levels. Player is able to pickup actor objects in any streaming level and move between the levels. Works fine, until you unload a streaming level behind you, then whoops… your inventory is gone. I looked at seamlesstravel - doesn’t seem to be workable with blueprints, and is for network state persistence more I think? I have a lot of pickupable actors - so I am not keen on spawning them into existence into the persistent level, as there a problems with collision if the streaming level in question isn’t loaded… plus complications about which actors to spawn, etc, etc.

Please tell me there is an easy way that doesn’t rely on my copy multiple actor states into my GameInstance, and rebuilding the actors from scratch in the new streaming level…!

Many thanks!

PS - Wouldn’t this be nice in blueprint: AActor->PersistToLevel(LevelName)


You could use the Game Instance class. It gets created when the game starts and only gets destroyed when you close the game, so its values will be preserved when switching levels. When you create a Game Instance class you also have to make sure you tell the engine to use it. You can do this by opening your Project Settings and in the Maps&Modes tab selecting the created class.

Thanks - but I’m not sure that will help. I already have a custom GameInstance which has a heap of variables I keep between levels. Works fine for keeping things alive… everything… but actors! An actor has to live in a map.


Aaaah, sorry about that :slight_smile:

Well, in this case I really have no idea sorry. There might be an easy way, but what I would try as an ‘emergency’ solution is to create a struct that holds all the required information about the pickup you want to keep. You could try and set up an array in the Game Instance type of your custom struct. When you switch levels, you add the actors you want to preserve to that array and load it up right at the begining of your next level. This way you might be able to fake the effect of “keeping” the actors. Please keep in mind that this is just an idea and there might be as well a straight forward solution to your problem that I am not aware of.


Well, now I realised that this is exactly that you mentioned you want to avoid in your orginial post, so sorry again, looks like I cannot provide any useful help, let’s hope someone else might can.

Thanks - yes, that is my current plan, but like you, I am looking for a better option without all the fiddly work. Surely this might be a regular issue? Carrying actors between levels must happen all the time…

Would having a “design” streaming level that only has the pickups in it work for you?

Edit: apparently didnt read the OP closely enough…

Attatch everything to a placeholder actor thats basically just a scene component with maybe a volume, stream THAT in, then detatch them and delete the placeholder? You may want to handle them as child actors too, but that makes detatching them more of a PITA than its worth.

Otherwise you may have to redesign your inventory to NOT store actor references.

  • old reply for posterity –

Dunno if this counts as complicated, but try:

  1. Get a list of all the actors you wanna stream in an array, get their corresponding classes, get their gamestates (HP, location, etc) and save this to an array (of dataStructs?) inside gameInstance.

  2. On level load, loop through this array spawning each individual actor from their classes and setting all the gamestste variables to the appropriate value*

Hello! This is waaayyy too late, but I have just found an answer for myself… When an actor is spawned, it is spawned in the persistent level and not the streaming level…So instead of placing the pickups in the streaming level, place a Bluepring that spawns the pickup item and then hides (turn of collision and hide) when the item is picked up. The spawner will be destroyed on level unload (as it is on the streaming level), but the item that was spawned will not be destroyed (as it is on the persistent level). So I use a banch of spawners instead of placing pickups individually on the level. Hope that made sense and helps someone in the future…