State of multiple UWorlds

Note: I did a cross post to AnswersHub: https://answers.unrealengine.com/questions/602604/syncing-actors-in-distinct-uworlds.html

I have a large world with one single level. I am thinking of using separate UWorlds to create detailed/to-scale maps of selected areas/interiors of that world. For now I am using separate sub-levels within the persistent level. Those are also persistent since the simulation there is essential for the whole game.

But this approach is limiting and needs some trickery to hide those levels from the player. So I started evaluating using multiple UWorlds. In each UWorld I then would run an detailed/to-scale sub-game and sync essential data between the main UWorld and all Sub-UWorlds.

So I guess, the goal is to have multiple persistent simulations which need to exists during the complete time of a match, are semi-independent and don’t conflict in regards to physics/levels.

So now I am evaluating using multiple UWorlds. How do they work, what is the state, how to integrate them with each other and what UE4 code maybe needs to be adapted. Documentation is very scarce so I am posting in this forum.

What I did so far is just this:


void SomeClass::SomeFunc()
 {
 FString PackageName = TEXT("/Game/Subfolder/NewWorld");
 UPackage* Package = CreatePackage(NULL, *PackageName);
 UWorld* NewWorld = GetWorld()->CreateWorld(EWorldType::None, true, FName("TestWorld"), Package, true, ERHIFeatureLevel::SM5);
 if (NewWorld != NULL) {
     UE_LOG(LogTemp, Warning, TEXT("Created UWorld."));
     TArray<ULevel*> LevelList = NewWorld->GetLevels();
     for (int i = 0; i < LevelList.Num(); i++) {
         ULevel *OneLevel = LevelList*;
         UE_LOG(LogTemp, Warning, TEXT("Found a level in new UWorld."));
     }
     return true;
 }
 return false;
 }

This code runs in principle and creates a new UWorld. However:

  • I have to provide an extra content folder ‘FString PackageName = TEXT(“/Game/Subfolder/NewWorld”);’] which does not contain assets referenced/used from within the default UWorld.

  • The first time I BeginPlay the game works. Then I stop playing and hit play again in the editor; I get a stack-trace which I attached. The game runs for a couple of seconds and then crashes for good.