Navemesh techniques around doors etc. - by scumble
scumble on 26/5/2006 at 07:55
After quite a bit of fiddling around with patrol paths, I'm now encountering problems with an AI getting through a couple of doors, despite the path looking fine. In one case it seems to get stuck trying to walk sideways in the doorframe - i.e. walking in and then and perpetually walking into the open door. In another case, it gets as far as opening the door, walks back, walks into the wall next to the door, closes the door and either tries again or wanders off to another PatrolPoint. I'll dig out some screenshots later.
Now, my suspicion is that the Navmesh around this door may be causing problems. When the doorframe is subtracted it creates a mess of triangles in the navmesh.
I can't seem to stop the doorframe from subtracting from the Navmesh, even though I've set AddSurfacesToNavmesh correctly.
In general though, this is a request for some people to comment on recent experience with getting AI to behave themselves, as I'd like to improve the coverage in the wiki - particular emphasis on specific tips in using Navmesh subtraction/addition.
Ziemanskye on 26/5/2006 at 08:41
AddSurface to navmesh?
Doesn't that make it so it generates nodes for climbing on the doorframe?
What you want is either for the mesh to subtract from the navmesh, or to create NavMeshSubtraction volumes around the uprights for the doorframe so that it's neat.
Also, make sure you positioned the door closed (you can set a property so it appears open in the level) so it's not trying to open the wrong way or from the wrong triggers.
Finally, Krypt suggested using the subtraction volumes to create a small tunnel around the door to force the NPC to only approach it from the correct angle (so it won't open the door in it's own face and get confused.
Rantako on 26/5/2006 at 09:28
Don't know about the doors, but setting CanSubdivideNavmesh: Subdivide_Never on doorframes seems to help (it basically stops the doorframe subtracting from the navmesh, so the AIs think they can walk through the solid parts - but it never caused any problems because the solid parts were so small). Also, with really problematic doorframes you could set Movement -> Physics: Phys_None so that the AIs actually can walk through the solid parts (though its so small you never notice it in game). It makes things a bit simpler for their pathfinding.
Ziemanskye on 27/5/2006 at 19:36
I think it's "rmode 26" in the console to see the navmesh in the game. Might help us see the problem more clearly.
Also the actual path node placements if he's on a script or something - if there aren't any either side of the door maybe putting them in will prove all you need.
scumble on 28/5/2006 at 09:46
I did actually try an extra PatrolPoint, but it doesn't necessarily alter the path to the door. I turned the door round so it opened the other way, and the AI didn't have any trouble then.
Here's the navmesh and path through the door:
Inline Image:
http://scumble.net/thief/path_debug.jpgThe door in quesiton is on the left. Also, the actors are hidden.
Ziemanskye on 28/5/2006 at 11:27
Is that even the same door?
I only ask because the blue mesh for the actual door is triangulated differently. And the distance to the corner and the presense of another doorway, you know :p
Just on the grounds that if it was always this same setup, then having the two doors so close together may have been part of it: I think there's a property for the distance from it an AI can open the door, which is by default 128 units from what I remember. If they're that close but not the same doorway maybe they were interfering (but it's less of a problem if you turn the door around because it doesn't have that 64 unit exclusion zone from the door itself). Just an idea, I don't actually know :sweat:
Also, you're blue path there is kind of hard to read. Here's what I think it's doing: Starting at the point on the right - it loops out of the first door, through the second, down some stairs we can't see the navmesh for, around something under that takes it off the bottom of the screen to a point on the right underneath. Is that about right? Given the 50/50s I'm also guessing there's a third point somewhere off the screen in the downstairs bit to make it a little more random which of the points on the right to go to.
If I was building that route, I'd have a path marker at either side of each door (about 32 units from the brush lines for the room), on at the top of the stairs, one at the bottom and similarly around any obstacles downstairs: I tend to have a lot of them, but it makes it easier to control the NPCs, and it means if you knock one off a path they don't have to go a long way back to get back onto their patrol. Means they "smoothe" less of the corners between each point too.
Just my style of building, of course.
scumble on 28/5/2006 at 21:05
Yes, I hadn't really described the configuration of the rooms - This is a two story house where I was trying to get the AI to walk between 3 different points - two of them upstairs and one downstairs, initially without any intermediate points to see how good the pathfinding was. I can see the benefit of having several points for the reason you pointed out - the AIs have to find their way back again.
I'll just have to see how things go as I progress. As level geometry is always different, it's difficult to have a uniform approach.