Spawn Actor in streamed-level

I dynamically spawn 3 spheres (actor-blueprints) on “event begin play”. However, I want each sphere to be spawned on a different stream-level. Because the real project has not 3 spheres but more like 300.000. So I need stream-levels for performance reasons.

But there is no build-in option in the editor (that I could find) to implement this.

Adding the code to the stream-level’s blueprint sadly still spawns them into the persistent level.

I tried Rama’s plugin ( (39) Rama's Extra Blueprint Nodes for You as a Plugin, No C++ Required! - Blueprint - Unreal Engine Forums ) but it doesn’t seem to work (for me) in the latest version.

Are there any other options besides C++ (which I have no knowledge of)?

It took a while to figure out how to spawn into a streamed level when using streaming levels, but after all my experimenting, it was quite easy in the end for what I was trying to achieve, so I hope this might help you out Napoleon.

I decided to switch my project over to using streaming levels, and when I tried to spawn my characters and objects, they all were spawned in the persistent level and were not visible on the streaming levels. After a bit of experimenting, here are the steps that I use to accomplish this:

  1. Create a new blueprint actor (I called mine SpawnHelper) and compile it (it really has no code in it at all).

  2. Drop the actor SpawnHelper into each level where I will want to spawn objects at runtime, and position them where I want to spawn.

  3. Open the streaming level directly in the editor, not the persistent level that contains all your streamed levels. This could get tedious with lots of streaming levels as you will have to do steps 4 and 5 for each streaming level.

  4. Select the SpawnHelper Actor in the world Outliner then right click in the Event Graph of the Level Blueprint and you can create a reference to SpawnHelper Actor. It will will show the reference as coming from persistent level, but since you are editing the streaming level directly in the editor this is fine.

  5. In the Event Begin Play, use SpawnActorFromClass, and set up the pins on how you want to spawn your actors, but you must drag a pin from the SpawnHelper reference to the Owner pin on the SpawnActorFromClass function call. This will then spawn your actor in the sub level where the SpawnHelper instance is.

You can then verify that this is all working fine by opening up the main level that contains all your streaming levels and playing in the editor. If you go to the world outliner and click the little down arrow to the right of the type column you can select level. Then you can see all your spawned actors and they won’t show up as being in the persistent level any more, they will actually show up as being in the right streaming levels.

My project is actually controlling the streaming levels from blueprints using LoadStreamLevel and UnloadStreamLevel, so I’m afraid I haven’t tested this with distance based streaming. I’m hoping if my game world ever gets big enough eventually I’ll switch the game areas to using distance based streaming, i’m just keeping things smaller for testing and proof of concept.

2 Likes

I dont get it GR… Could you send me your project?

I had the same problem, but GRWalton you helped me solving it thank you!

First:
I used “createInstance” to generate random streaming levels
the actors only spawned in the persistent level

Then:
now I use “LoadLevelInstance” and it works totally fine. I don’t even needed the SpawnHelper from GRWaltons post

thanks!

Thank you very much!!!
That’s a good solution, to set the owner of the object to spawn to an object of the streaming level. It works perfectly

Specifically the information in step 5 fixed my problem. Thanks!

The “Owner” part is the most important part here. When spawning a new Actor and setting the Owner parameter in the SpawnActor node will ensure they spawn in the same streaming level. I don’t really like the rest of the implementation as it’s very static and manual work,you can roll your own solution of course.

For C++ I have another solution for after the Actor is spawned and needs to move:

bool ULZGameplayStatics::MoveActorToLevel(AActor* ActorToMove, ULevel* MoveToLevel)
{
	if (ensure(ActorToMove))
	{
		return ActorToMove->Rename(nullptr, MoveToLevel);
	}

	return false;
}

I think this is not the complete solution, a little more is required. Refer to: Move actors between levels c++ - World Creation - Unreal Engine Forums

I’m not sure that’s the correct solution but using only the ‘rename’ causes some weird issues in some of my cases:

Add:

// Remove from world
GetWorld()->RemoveActor(Actor, true);

// Rename and move it to the level and add it to the list
Actor->Rename(*Actor->GetName(), Level);
Level->Actors.Add(Actor);

This solved the issue for me!
Thank you so much!