Creating a navmesh with ladders

I’m trying to implement the ability in my game for the AI to climb ladders and stand on roofs.

This is a part of my “scene” that im working on: http://i.imgur.com/VKMQOPe.png. the red mesh is a hand drawn nav mesh i made (starting with a plane mesh then extruding/subdividing/cutting it). when i load the scene i supply the navmesh geom to the navmesh generator and then remove it from the scene. The ground and ladder are currently hidden to help show what the nav mesh looks like, but you can see where they would be.

the NPC spawns at the bottom of the house, and then i give him a destination corrdinate on the roof. what I’d like for it to dois come up with a path the ends up on the top of the house with waypoint/s on the vertical ladder portion of the navmesh.

what ends up happening is i get a path that puts the NPC inside the house directly under the roof coordinate where he should be going.

Right now im not worried about how he will actually climb the ladder, I’m just trying to get the navmesh plugin to generate a path through the ladder and on to the roof.

Does anyone have any suggestion on how i can make this work?

@icamefromspace said: I'm trying to implement the ability in my game for the AI to climb ladders and stand on roofs.

This is a part of my “scene” that im working on: http://i.imgur.com/VKMQOPe.png. the red mesh is a hand drawn nav mesh i made (starting with a plane mesh then extruding/subdividing/cutting it). when i load the scene i supply the navmesh geom to the navmesh generator and then remove it from the scene. The ground and ladder are currently hidden to help show what the nav mesh looks like, but you can see where they would be.

the NPC spawns at the bottom of the house, and then i give him a destination corrdinate on the roof. what I’d like for it to dois come up with a path the ends up on the top of the house with waypoint/s on the vertical ladder portion of the navmesh.

what ends up happening is i get a path that puts the NPC inside the house directly under the roof coordinate where he should be going.

Right now im not worried about how he will actually climb the ladder, I’m just trying to get the navmesh plugin to generate a path through the ladder and on to the roof.

Does anyone have any suggestion on how i can make this work?

If you are letting the navmesh stuff generate the mesh for you, I’d suggest using a slanted quad in place of the ladders, batch the geometries and then hand this off for generating the nav mesh.

As long as your scene isn’t constantly changing ladder positions, you’ll only be taking a performance hit when you batch the single time you’d need to (per loaded level or whatever).

Actually, I can’t remember the specifics about how navmesh goes from line to line, you may have to do some vert welding on the batched mesh.

EDIT: Scratch this, I remember now. No need to do this as long the geoms that are batched are touching/overlapping.

just to make sure were on the same page. when i say i’m using the hand drawn geom to generate the navmesh im doing

[java]
NavMesh navmesh = new NavMesh(sceneNode.getChild(“GroundNav”));
sceneNode.getChild(“GroundNav”).removeFromParent();
//no need to batch geoms, i have one single mega mesh made in blender
[/java]

I’m not generating in the sdk or anything

@t0neg0d said: Scratch this, I remember now. No need to do this as long the geoms that are batched are touching/overlapping.

theyre not “touching” such that two edges ever intersect, but theyre overlapping in the sense that the npc can walk inside the house (not greatly show in the screenshot because the house covers it up) or he can walk on the plane on top of the house. (i dont think this is what youre talking about just wanted to make sure)

I’d suggest using a slanted quad in place of the ladders

does this suggestion to give the ladder some depth still apply knowing that the navmesh is already one big funky plane to begin with? (eg no batching is done)… the ladder portion of the nav mesh is just the plane being extruded vertically, then horizontally again to add the navmesh on the house’s roof

@icamefromspace said: just to make sure were on the same page. when i say i'm using the hand drawn geom to generate the navmesh im doing

[java]
NavMesh navmesh = new NavMesh(sceneNode.getChild(“GroundNav”));
sceneNode.getChild(“GroundNav”).removeFromParent();
//no need to batch geoms, i have one single mega mesh made in blender
[/java]

What do the ladders look like in the navmesh you created in blender?

EDIT: Basically what I’m getting at is, the ladders should look like a quad or multiple quads one after the other depending on how many nav steps you want generated on a single ladder (a non-complex shape that only allows traversal where you would want it). The quad(s) should be at the same angle that the ladder lies. So… from a side view you would see:

Hope this formats properly

________
        |\
        | \
        |__\_____

My game is pretty much all cubes and planes, its very prototypy right now: this is the scene in game: http://i.imgur.com/KmOoSlz.png

the player is the ninja, sinbad is the ai. sinbad is chasing the ninja.

for the player I get him up the ladder by using collision detection to see if hes in front of a ladder while pushing W, if so i change his walk direction to be (0,1,0) instead of the normal forward until he makes it to the top of the ladder, where he resumes normal walking behavior.

I’m trying to do the same for sinbad. but the problem is that the path finder doesnt buld a path that bring sinbad to the ladder, so the code that detects he is trying to go up a ladder doesnt even have a chance to come in to play., instead sinbad is getting routed into the inside of the house underneith the target coordinate (even though the final vector on the waypoint list is the ninja, the second to last waypoint is the ground inside the house under the roof.

i kind of see what youre saying about being slanted, i guess in reality the ladder would be leaning against the building (unless its like a fire escape ladder something).

Im about to try removing the navmesh on the ground floor of the house, to so if then he’ll take the ladder, if not ill try to make ithe ladder nav mesh slanted. not sure what to try after that.

Ah… I get ya now…

So, are the walls of you building part of the nav mesh? If so, you may want to consider removing them, leaving gaps in there place and making vertical faces traversable. This way, at least the path will be generated properly, then you just need to worry about physics :wink:

EDIT: I think this is how I did it with that dungeon generator thingy I put together. Physics got a simplified version including walls, navmesh got a version with gaps where walls should be and I did some significant altering to the path returned to ensure it used as few steps as possible to get from point a to point z.

this is a screenshot of my navmesh in blender in edit mode: http://i.imgur.com/qumLf4Y.png i have gaps where the walls are. sinbad just doesnt like the ladder portion or something for some reason.

When you view the points on the path, does it actually go up the ladder? i.e. is it a problem with the path? Or is the problem traverse the 90 degree angle?

yeh its a problem with generating the path itself. ive run it several times and looked at the generated paths. they all bring sinbad in to the lower floor, then on the very last point of the path is the actual target.

Its almost as if it thinks because the two floors are on top of eachother that sinbad can reach the top floor from the lower floor (which he can not, he must go outside and use the ladder)

btw this is my path finding debug app state turned on showing the path that sinbad is incorrectly taking.

red dots are the waypoints (which are also listed in the top left)

@icamefromspace said: btw this is my path finding debug app state turned on showing the path that sinbad is incorrectly taking. http://i.imgur.com/62SeOM4.png

red dots are the waypoints (which are also listed in the top left)

Interesting… there is a setting for max traversable slope in nav mesh (I can’t remember what the method is), what do you have this set to?

hmm i dont see any methods on NavMesh that look anything like you cant set any kind of configuration, it just kind of takes your source mesh and has a couple other methods that look like theyre meant to be used internally by the NavMesh and the PathFinder.

Perhaps it was removed or something? in the sdk though i know there is some kind of setting like that (amongst many other options, not seen in the NavMesh class) when you generate in the SDK. I’m not sure what those values plug in to though

@icamefromspace said: hmm i dont see any methods on NavMesh that look anything like you can set any kind of configuration, it just kind of takes your source mesh and has a couple other methods that look like theyre meant to be used internally by the NavMesh and the PathFinder.

Perhaps it was removed or something? in the sdk though i know there is some kind of setting like that when you generate in the SDK. I’m not sure what those values plug in to though.

Doh… I know why. I forked navmesh a while back to alter a few things in it (mostly having to do with not creating obscene paths over complex geometries and to fix an issue with navmesh generation at the time. If you grab the code, you’ll see all these setting are hardcoded in one of the classes currently.

ah thanks, where can i download the code from?

I actually may have re-ported the original code from critterAI… but I don’t recall doing this. I likely added stuff that had been updated since the JME port.

EDIT: Or rewrote the path-finding classes. /sigh… it’s been over a year now… so I can’t remember =( I can’t even remember what I had for lunch >.<

@icamefromspace said: ah thanks, where can i download the code from?

Let me see if I can track it down… one moment.

Here it is:

https://github.com/jMonkeyEngine/jmonkeyengine/tree/master/sdk/jme3-navmesh-gen

Ugh… I think I linked the nav mesh generator. Still trying to find it.