Dynamic Navigation Mesh

Hey there,

I’m currently working on a third-person shooter where the player has the posibility to build objects inside the world to defend himself against enemy waves.
I was wondering if it is possible to use a dynamic navigation mesh that updates everytime the player spawns an object.
Maybe by using some kind of technique where you add the object to the navigation mesh as a point of intrest for the AI.
I thought I could use an array of all the objects that where placed and when the AI get’s near one of them he will attack them, but performance wise I don’t think this will be completly optimized.
Also when I spawn an object and the path is blocked by a spawned object the AI’s navigation is broken because th AI still thinks he can pass.

Kind Regards
Dyronix

1 Like

It’s perfectly doable, and it’s actually a really well tested use case since that’s what Fortnite essentially does in terms of navigation. You need to make sure you have navmesh configured for runtime generation (do that via Project Settings → Navigation Mesh → Runtime Generation) and it should work out of the box.

A word of advice: whenever possible mark the items build-able by player as navigation obstacles (there’s an option for that in Static Mesh editor, in Navigation section of the properties). The upside of using obstacles is that it’s a lot faster to rebuild navmesh tiles. The downside is that obstacles annotate navmesh, but do not create new walkable areas, so creating an AI-walkable staircase with obstacles is not possible.

For more tips regarding tweaking navmesh generation see this twitch stream I did some time ago: - YouTube

Cheers,

–mieszko

6 Likes

Thanks for the answer, I’ll take a look at it.