Dynamically Spawned Level Instance Actors do not have their sub actors world partition stream in PIE starting level

We are building levels where we spawn in Level Instance actors at runtime that have World Partition enabled into a Persistent level that also has World Partition enabled. We have noticed none of the actors that are part of the level instance stream in and out when playing in PIE for the level you start in. They properly stream if we transition to a different level and back while playing. It also works correctly in Stand Alone.

After some digging, it appears it is related to the call ILevelInstanceInterface::SupportsPartialEditorLoading() returning false if the Persistent level has the PKG_NewlyCreated flag.

ILevelInstanceInterface::SupportsPartialEditorLoading()

// If the level instance actor (or any parent actor) is unsaved, don't partially load. if (Actor->GetPackage()->HasAllPackagesFlags(PKG_NewlyCreated)) { return false; }However, by default the engine will always add PKG_NewlyCreated to the PlayWorldPackage for the Persistent Level you are starting PIE in

UEditorEngine::CreatePIEWorldByDuplication

UPackage* PlayWorldPackage = CreatePackage(*PlayWorldMapName); // Add PKG_NewlyCreated flag to this package so we don't try to resolve its linker as it is unsaved duplicated world package PlayWorldPackage->SetPackageFlags(PKG_PlayInEditor | PKG_NewlyCreated);Unsure if this is the appropriate fix as there are other places in the Level Instance / Streaming code that check against PGK_NewlyCreated for other reasons, but I was able to get the runtime spawned Level Instance streaming to work in the level you start PIE in with the following change:

ILevelInstanceInterface::SupportsPartialEditorLoading()

// If the level instance actor (or any parent actor) is unsaved, don't partially load. if (Actor->GetPackage()->HasAllPackagesFlags(PKG_NewlyCreated)) { if(!Actor->GetPackage()->HasAllPackagesFlags(PKG_PlayInEditor)) // CHANGE - Exclude PlayInEditor types of NewlyCreated return false; }

Hello,

Could you provide the repro steps? It would be helpful for making sure that I’m on the same page. A stripped-out vanilla project with the issue isolated would be even better, but the repro steps alone should be adequate enough for now.

Thanks,

Ryan

Hi,

I have attached the test I did in stock unreal. I took the FirstPersonShooter project and on the FirstPersonMap moved a few static mesh assets to its own level instance. I colored the meshes with the walnut texture for better visibility.

Then on this level in BeginPlay, I spawn in a blueprint that spawns a dynamic Level Instance actor that sets the world asset to the LI I made and immediately loads it. I also dramatically turned down the streaming distances for testing.

If I press PIE, the walnut assets are always there even though the rest of the scene assets are streaming with my player distance.

If I press play in Stand Alone, the assets properly stream. They also properly stream in PIE if I start in “StarterMap” and then press “M” to scene transition to the FirstPersonMap.

[Image Removed]

Instead of spawning a level instance actor at runtime, which I’m not sure is supported, you can instead just use “Load Level Instance”.

-Ryan

We’re using Level Instance actors for a few reasons that were nice:

  • We are using the same Level Instance spawning manager to handle spawning the Level Instances in edit mode for being able to preview what our levels would look like. Using Level Instance Actors in this case was nice.
  • We have subclassed off of LevelInstanceActor with ReplicatedLevelInstanceActor that handles spawning in the specified random level instance for clients when they join as the manager that had spawned in the level instances has sort of fired and forgot at that point.

We’ve been using this system for a short while now and it has been working for us so far. The only hiccup we’ve seen was the PIE streaming inconsistency this thread is noting. That and I posted our workout do deal with that too. Just wondering if that seemed like a logic fix or if there was some other issue in the engine once digging.

Thanks for the additional details. After I took another look at the repro project, I also missed that you were already aware of LoadLevelInstance. I created a JIRA for this issue that can be tracked here: Unreal Engine Issues and Bug Tracker (UE\-295514\). I don’t have an ETA, as priorities for bugs and features can shift at any time.

-Ryan