"Dynamic" NavMesh

First, jme3 ai is only good for simple path finding. What you are showing us in this image is its major fault of only being able to build a solo mesh, i.e. a navmesh consisting of one tile.

Second, this stuff gets real complicated real fast.

To do dynamic navmesh like you want requires a tiled navmesh and a tile cache. This allows you to build a single cache of tiles identical to the navmesh of tiles to swap out when an object blocks part of the navmesh.

As an example, someone pushes a box onto a tile and that box now blocks the path across that tile. You cut a hole into the navmesh by removing that tile that has been blocked by the box. The path finding routine will find there is a hole in the navmesh and try to find a path around it if possible or just end at the nearest walkable tile. You can only cut squares from a navmesh but you can use a circle or boxed shaped object to do the cutting i.e selecting of what tile to remove. Recast will accept only those two shapes if I remember correctly. Basically barrels or boxes.

If the offending box gets removed, simply grab the tile from the cache and insert it back into the navmesh and you now have a walkable tile. Recast does this all for you.

I can give you examples of building a tiled navmesh but they relate to a stalled project I was assisting someone on. Although it is specific to that project, I explain the process of building a tiled navmesh and tile cache. This project is based off recast4j.

I suggest reading that wiki I linked, not just the two linked parts of it, as its loaded with details on whats going on with recast4j. Recast 4j is still very actively maintained and well worth the effort to try to learn.

Read the wiki homepage for the example project I linked to for links to recast4j.

Each part of recast4j has a test folder that contains tests that give great clarity to how each part works but it will require lots of reading to figure things out. I spent a year on it myself but I am not as skilled with java as most here so others were able to figure it out in weeks or days. As I was a newbie java programmer, I would get side tracked learning other things just to continue on with recast4j.

Hopefully your journey will be shorter than mine. I am sidelined with real life still so I cant really help as much as I would like. You could try to use that project I linked to as a wrapper but it will require alot of effort to get working as its not finished.

See this link to try and do that.

https://hub.jmonkeyengine.org/t/solved-a-problem-in-using-navmesh-downward-face-normals/43504/4

5 Likes