Download

How to spawn navmeshes

So I’m kinda tired of my custom pathfinder exploding all the time so I decided to go ahead and try this once again: spawning nav meshes on the fly

so far it… kinda works :o :wink:

here’s how it goes so far:

  1. made a class DynamicPylonSpawnable extends DynamicPylon with bStatic=false and bNoDelete=false
  2. placed on in my level with a specific size, built the paths. this is what I’ll use as a template
    navmesh1.jpg
  3. in code I find the DynamicPylonSpawnable in the level, and use it as Template to Spawn a new one
  4. after spawning it I call RebuildDynamicEdges() in it
  5. hope it works. otherwise do it again
  6. profit.

see it in action:

when the enemy sees me he just turns around like crazy as he can’t reach me (no navmesh path to go).
after spawning a navmesh box (which I show with ‘show paths’) he’s able to find a path towards me

it even seems to connect with other (existing or newly spawned) navmeshes.
but it doesn’t always work. sometimes I spawn it and it doesn’t seem to update it. also if I spawn it next to an existing navmesh that is sitting at a different height, it will skew it to connect it (probably doesnt have enough polygons to ‘build’ a ramp)

ok apparently spawning a “new” navmesh invalidates the one used as a template. so all I’m doing is moving it around :confused:

at least this confirms that this whole thing could be done by pre-placing an array of platforms in the editor, building the paths on them, and then putting it in place by the random level generation code