[UE5.4] How do levels work?

Ok. So I learned a LOT in the past hour or so.

Loading a level takes time. A LOT of time. In C++, when you call OpenLevel, it needs to do a LOT of stuff and both levels will be active for a while. It needs many many ticks before the new level is ready. So I indeed do need to know when the level is finished loading. OpenLevel is NOT synchronous. Yes, it does a lot right away, but not everything. Not even close.

IOW, you can’t use a level immediately after OpenLevel() in C++. The funny thing is that I’ve seen plenty of people asking how to know when a level is done loading and there’s never an answer. Well, GameInstance::LoadComplete() will be called when the level is ready. OnWorldChanged will be called MUCH MUCH earlier. But this is the only reliable way I’ve found to get a reference to the new world/level.

I’ve now got the level kinda working. The player character is even at the correct location and I can move the camera around. Only problem is that the navigation system is sometimes null. Again, I believe this is a delay issue. It’s just not ready yet. Because if I put breakpoints in the debugger, it works fine. IOW, it’s had enough time to set itself up.

So I’m gonna look into seeing if I can detect when the nav system is initialized.

Anyways, huge progress.

edit: My PlayerCharacter has finally teleported to the new level. AWWW YISSS!!! It’s starting to work.

edit2: Argh… was using the wrong world for getting the nav sys.

WOOHOO!!! IT WORKS!!!

I can switch levels. Even the level instances work great.

3 Likes