Is there a way to wait until the navmesh has been completly generated?

Hi, I have a random level generator that generates a random layout for a bunker.

The generation code is called inside the constructor of the game mode so that no player is spawned at that time. The problem is that because I am adding meshes, the navmesh has to be rebuilt, and afterward, the enemies are also placed randomly on the walkable navmesh. Now the problem is that I call

UNavigationSystemV1::GetCurrent(GetWorld())->Build()

but that doesn’t seem to wait until the navmesh generation is completely done which results in the enemies spawning all at one spot.

If I call the code later as an example OnNavigationGenerationFinishedDelegate the Enemies’ locations are correct but the player was already able to walk around which shouldn’t be the case.
I could write a lot of code to prevent that from happening by forcing the player to spawn as a spectator until the delegate is called but I am sure there is a better way and I am just too stupid to find it. Maybe also someone could say if there is a better place to call the logic instead of the game mode. I didn’t want to do it in blueprint inside the level since that would mean that everything has to be blueprint callable and I want to have it independent from the maps.

Thanks in advance :slight_smile: .

Ok found a, well let’s call it a workaround. I now will spawn the enemies directly before the first player is spawned inside the PostLogin function (i call my spawn function inside it :slight_smile: )

If anyone has a better idea or solution i would be happy to try it :slight_smile:

This is what load screens are for – if you’re busy generating data, throw up a loading screen and clear it when you’ve got what you need

@eblade Yeah you are right but still don’t know how I can be sure that the nav mesh is completely generated :frowning: can you maybe provide a link to a lifecycle overview where I can see what method I have to implement myself and on which actor?

Didn’t find anything useful.

Thanks in advance

I think you said it yourself :slight_smile: I think my project has a bunch of delegates that all get fired when various things are done loading, and the code that provides a loading screen just doesn’t clear it until all those events fire.