OnLevelLoaded is called before level finishes initializing?

Hello, I have a randomized dungeon that loads in random rooms (maps):

ULevelStreamingDynamic* levelObj = ULevelStreamingDynamic::LoadLevelInstanceBySoftObjectPtr(GetWorld(), level, loc, rot, success);
levelObj->OnLevelLoaded.AddDynamic(this, &AMapHandler::LevelLoaded);

LevelLoaded() is called immediately, but the levels aren’t actually loaded yet. They take a few seconds for all the actors to actually appear.
(I’ve tried waiting a few seconds, but some levels still load slower with breaks code)

Is there a way I can know if the level was fully loaded, including all the actors within it?

Note: This works perfectly when I use bShouldBlockOnLoad, but then loading screens are frozen. =(

1 Like

If I remember correctly I had this problem during one of the Epic Game Jams where I was using Level Streaming as well (Blueprint-only project). My workaround was to manually update the streaming levels in a tick function.
In the first pass I would set “Should Be Loaded” as well as count the number of levels to be loaded and the number of levels to be visible
In the second pass I would then count the number of levels that have finished loading using “Is Level Loaded”.
In the last pass once the number of levels that should be loaded was equal to the number of levels that had actually finished loading I would once again manually set “Should Be Visible”.

Unfortunately, I never actually got around to debugging what was going on under the hood.

Disclaimer: it’s been almost two years so things may have changed and/or my memory may not be 100% accurate, but hope it helps regardless.

I’ve had the same problem. I believe OnLevelLoaded apparently just tells that the level has loaded, but not that it is completely spawned in the world yet. What the use of that is, I have no clue, and honestly i think it’s misleading.

How I solved it, is to listen to FWorldDelegates::LevelAddedToWorld.
This seems to only fire when levels have actually loaded and spawned their actors.

Of course, as it’s a more global delegate, you would need to filter out for the levels you are interested in.