This question explains & answer how to stream in a level at a location. As described, I set the LevelTransform on the StreamingLevel before requesting it to be loaded. However, despite the transform being correct, the level is still based around the origin.
Digging in to it I see that when we come to UWorld::AddToWorld
, the bAlreadyMovedActors
flag has been set to true so the transform is never applied. Further looking reveals it gets set to true in this bit of code:
UWorld* PIELevelWorld = UWorld::DuplicateWorldForPIE(NonPrefixedLevelName, PersistentWorld);
if (PIELevelWorld)
{
PIELevelWorld->PersistentLevel->bAlreadyMovedActors = true; // As we have duplicated the world, the actors will already have been transformed
check(PendingUnloadLevel == NULL);
SetLoadedLevel(PIELevelWorld->PersistentLevel);
// Broadcast level loaded event to blueprints
OnLevelLoaded.Broadcast();
return true;
}
This is inside ULevelStreaming::RequestLevel
. I’m not really sure what the comment means, but the level is definitely the new level being streamed in (why it is called the PersistentLevel I’m not sure, it isn’t the persistent level - just a duplication of the persistent world…).
Also, the fact that it is talking about PIE (PlayInEditor) makes me worry this is going to be an editor only issue…
How do I correctly apply the transform to the level?
Update
Commenting out the setting of bAlreadyMovedActors
in the above sample does “resolve” the issue, so it is at least related to that.