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 .