Krypt on 25/2/2005 at 07:33
I'm not sure if any of you have gotten this far in your map-making endeavors, but I thought I'd write up a tutorial about the Navmesh since it was something I did a lot of work on at ISA. I'm writing this from memory, so bear with me if I don't get names of properties and such exactly right. EDIT: Fixed it up with more specific instructions, so hopefully this tutorial will actually be accurate now for the most part.
The Navmesh is a set of nodes created on all the floors in a map that the AI uses to navigate. You can build the Navmesh by doing a Build all on your map, and there is also a button up on the top toolbar that looks like a couple dots connected with lines that will build only the Navmesh. Make sure you have your bsp built before using that second one, or else it won't work. Once you've built the Navmesh, you should be able to view it by clicking the button above your 3d window that says "NavMesh Nodes" when you mouse over it. You should see a bunch of red triangles with little Y's in the middle of them checkered all across your floors. The automatic building is nice for areas with simple geometry, but for a fully-detailed map, you have to do a lot of tweaking to clean up the Navmesh and make it easy for the AI to traverse. In some cases you have to build almost all of it manually. It is also nice to have a clean and simple Navmesh because it can reduce the build time from 5~ minutes down to 1 or less for a large level.
A simple rundown of how the Navmesh works... When the AI is navigating a level, the only thing it pays attention to is the Navmesh. It does not know about level geometry. If there is Navmesh underneath a solid wall, the AI will run into the wall forever because it thinks it can walk through it. You never want to have Navmesh underneath objects the AI will physically collide with (exception being moveable physics objects), and you also don't want Navmesh in places the AI has nothing to stand on, such as floating in the middle of the air. Another important thing to note is that the Navmesh must always connect in order for the AI to walk across it. If there is a 1-unit gap between Navmesh nodes, it may as well be as wide as the Grand canyon, because the AI will never be able to cross that gap.
The Navmesh subtraction volume is your best friend for Navmesh simplification. You can create a Navmesh subtraction volume with your builder brush, by clicking the button on the left toolbar that looks like a translucent blue cube and says "Volume" when you mouse over it. When you click that, a menu pops up with a list of all the volumes you can create. Select NavmeshSubtractionVolume and your volume will be created. The Navmesh subtraction volume's function is pretty self-explanatory... it subtracts from the Navmesh. If you place a cube-shaped Navmesh subtraction volume in the middle of a floor and rebuild the Navmesh, you'll see that no Navmesh is built where the volume is. It can also be used to add to the Navmesh, which can be handy in certain cases. There are properties you can add to the volume the tell it whether to add or subtract from the Navmesh. To add these properties to your volume, open up its properties, right click on Properties>Add property and scroll down to Navmesh on the list of property categories. In here you'll see "AddSurfacesToNavmesh" and "CanSubdivideNavmesh". These are both booleans which allow you to set if the volume will add or subtract from your Navmesh. If you take the volume in the example above and add the "AddSurfacesToNavmesh" property and set it to True and rebuild, you'll see that Navmesh appears on top of it in mid-air. As I said above, you don't want to do this in a real map because the AI will try to walk on the Navmesh there even though there is nothing for it to actually stand on, which won't be pretty.
Another important tool for cleaning up your Navmesh is the ability to turn off Navmesh on bsp and static meshes. Turning off Navmesh on bsp is easy, just select a bsp surface, right click and look at the surface properties. Under the Flags tab you'll find a "Do not add surfaces to Navmesh" option which allows you to disable the Navmesh for that surface. Be sure to do this on places like rooftops, the tops of walls, and basically any surface you don't want AI to try to walk on. For static meshes, just add the same properties I listed above for the Navmesh subtraction volumes that allow you to choose whether to add/subtract from the Navmesh. I believe static meshes subtract by default.
So now, what do you use the Navmesh subtraction volume for, anyway? You'll notice if you add a fancy static mesh into the middle of your floor, such as a cylindrical pillar then rebuild your Navmesh, that all of a sudden the nodes look really crazy. The automatic generation will try to build Navmesh that matches exactly with the static mesh's collision hull. In most cases, you don't want it to do this because it creates a million tiny nodes and makes it harder for the AI to navigate. What you do to solve this problem is set the pillar static mesh to NOT subtract from the Navmesh, then build a Navmesh subtraction volume around the base. Just make the volume a cube that encompasses the base, don't worry if it doesn't match the base of the column exactly. It won't make much difference in the navigation unless there is a considerable amount of space that you're subtracting from that the AI should be able to walk on. This will make a nice and clean square-shaped gap in the navmesh surrounding the pillar, and will allow your AIs to navigate the room without any problems.
So why would you ever want to use a Navmesh subtraction volume to add to the Navmesh? You generally use these for static meshes the AI can walk on, such as bridges and most commonly, stairs. You always need to do these for stairs, or else your AIs might get stuck and be unable to walk up and down them. Assuming you've already built some stairs, first create a Navmesh subtraction volume shaped like a ramp that approximates the rise/run of your stairs. Set this volume to both add and subtract from Navmesh (so the AI doesn't try to walk under the stairs) and turn off Navmesh add/subtract on your stair static mesh(es) or bsp surfaces. If you don't do it this way, each step will have its own set of nodes, which will sometimes not connect properly and are just messy in general. Now if you want to add a static mesh bridge to your map, just create a Navmesh subtraction volume whose top surface is level with the area you want the AI to walk on and set the volume to add to Navmesh, and turn off add/subtract on the static mesh(es). This technique is especially useful if you have, for example, a walkway made out of many smaller static meshes, as it creates a smooth Navmesh across the top and doesn't force it to try to build on top of every little piece.
Here are some other random notes about Navmesh subtraction volumes. You can make them any shape you want, they don't have to be cubes. Just make sure they're valid brushes and they should work fine. Don't be afraid to mess with the vertices and change the shape after you've created the volume, it will still work even if you adjust it. Corruption from too much resizing or copy/pasting is a concern for normal volumes used for other purposes, but it doesn't apply to Navmesh subtraction volumes. Also, they don't add to the memory or filesize of your map in the end, so feel free to add as many as you need to get a clean Navmesh.
Now for a quick and very dirty tutorial on patrol paths. So you have an AI guy in your map and want to make him patrol around? A simple back and forth patrol is pretty easy to put together. First you need to place an AddAIPoint near the AI you want to patrol. This can be found in gamesys under Marker>AIPathPoint. When you place it near the AI, you should see a little yellow line draw between it and the AddAIPoint. This shows that this AI is associated with this AddAIPoint, and once your patrol is created, the patrol attached to it. Next, add two PatrolPoint actors. These represent spots the AI will walk between when patrolling. Now you need to connect them together. First you need to enter Patrolpoint connection mode. Do this by clicking the button on the left toolbar near the top that looks like two green spheres with an arrow pointing from one to the other. Once you're in the connection mode, select the AddAIPoint and Shift+click the first PatrolPoint. You should see a line with an arrow on it draw between them. This means the AI will walk from its current position to that patrol point when the map starts. Next select that PatrolPoint and Shift+click on the other one to connect them. (If you ever want to disconnect two points, just select the first point again and Shift+click the destination point and it will remove the link between them) Do the same from the other PatrolPoint to the first one. That's it, you now have a simple patrol path. Make sure your map has a Navmesh and test it out.
Quick summary of the functions of some of the other types of points you can use in a patrol:
ChangeDirectionPoint - When the AI gets to this, he'll turn around and go back around his patrol path in the opposite direction. Put one of these at either end of a patrol path made up of multiple PatrolPoints that you want the AI to patrol back and forth on. You only need to connect the path for one way, it will automatically reverse the path when the AI reaches one of these points.
LookPoint - Connect a PatrolPoint/ChangeDirectionPoint to one of these. Causes the AI to stand on the PatrolPoint and face the direction of the LookPoint and stand there for whatever amount of time is specified in its properties.
PlayAnimationPoint - Same as a LookPoint, except it plays an animation.
HeadTurnPoint - Used the same way as a LookPoint, except the AI will keep walking while turning his head to look at the HeadTurnPoint.
FleePoint - You don't actually connect this to any patrols, this is an object placed on its own. When an AI is fleeing, it will try to run to one of these to hide.
WanderPoint - When the AI gets to this, it'll wander around randomly within the radius specified in its properties. Note that if you place this in a patrol path, the AI will never go back on its patrol once it gets to this point, it will wander indefinitely.
There are a few handy Navmesh debugging features available in the editor. The first is called NavMesh links mode, and is viewable if you hit the button to the right of the NavMesh Nodes button. This shows the links between Navmesh nodes, which are basically the paths the AI will try to walk on when walking through the level. There is another helpful tool for debugging patrol paths available in the path connection mode. While in path connection mode, multi-select two PatrolPoints. A cyan line will draw between them. This represents the path an AI would take trying to walk between these two points. If you select two PatrolPoints on opposite ends of a level, the cyan line will wind through the level, taking the shortest path it can find to get to the other point. If you do not see a cyan line that means that no path can be created between the two points, and your Navmesh will need to be adjusted to connect properly or be wide enough for the AI to fit through. Both of these features are helpful when you have an AI that won't walk through a doorway or over a thin bridge and similar situations.
That is all I have for now. If anyone has any requests for additions to this or if I think of anything else to add to it then I'll edit it in.
Brodieman on 25/2/2005 at 12:26
Thanks a lot mate i was just about to start fiddling with some AI in my extremely rudimentary map so far. :)
d'Spair on 25/2/2005 at 18:10
Quote Posted by Brodieman
Thanks a lot mate i was just about to start fiddling with some AI in my extremely rudimentary map so far. :)
The same with me. I added an extra brutal ebil Hammerite, and the game said I had no navmeshes, now it's clear for me. Thanks a lot!
Eshaktaar on 25/2/2005 at 19:39
Thank you for taking the time to help us out, Krypt.
Quote Posted by Krypt
Unfortunately, I can't recall how exactly you enter this mode, but I think you click a button on the top toolbar.
It's in the left toolbar, the icon with the two green spheres connected by an arrow.
Krypt on 26/2/2005 at 00:22
Ok, I edited the tutorial. I actually downloaded the editor today and loaded it up really quick so I could write some better instructions for these things. Everything should be accurate now, plus I added a little bit about Navmesh debugging at the end of it.
Murmel on 26/2/2005 at 11:04
Thank you very much :)!!
Mandrake on 5/3/2005 at 01:25
Quote Posted by Krypt
The Navmesh is a set of nodes created on all the floors in a map that the AI uses to navigate. You can build the Navmesh by doing a Build all on your map, and there is also a button up on the top toolbar that looks like a couple dots connected with lines that will build only the Navmesh. Make sure you have your bsp built before using that second one, or else it won't work. Once you've built the Navmesh, you should be able to view it by clicking the button above your 3d window that says "NavMesh Nodes" when you mouse over it. You should see a bunch of red triangles with little Y's in the middle of them checkered all across your floors.
Is it normal for only parts of the navmesh that are very near the camera view point to be visible ? At first I thought it wasn't working because I tend to have the 3d view fairly high up looking down at an angle, but I eventually discovered if I went down closer, it started appearing.
Is there any way to see all visible navmesh at once from a distance ? Or at least a greater distance than now ? As it is now I have to move around the map and get quite close to a region before each bit appears, making it hard to get an overall impression.
Krypt on 5/3/2005 at 01:47
Quote Posted by Mandrake
Is it normal for only parts of the navmesh that are very near the camera view point to be visible ? At first I thought it wasn't working because I tend to have the 3d view fairly high up looking down at an angle, but I eventually discovered if I went down closer, it started appearing.
Is there any way to see all visible navmesh at once from a distance ? Or at least a greater distance than now ? As it is now I have to move around the map and get quite close to a region before each bit appears, making it hard to get an overall impression.
Yes, by default it will only show the Navmesh within a certain (fairly short) radius of the view camera. To show all the Navmesh at once, right click on the top bar of your 3d window and go to View>AI Navmesh>Disable Level-of-Detail (LOD) rendering. I think the LOD thing was implemented to save on performance, but I never found that viewing the Navmesh slowed it down very much. I always have the LOD off unless I'm trying to look at just a small area and the extra Navmesh gets in the way.
Mandrake on 5/3/2005 at 03:54
Quote Posted by Krypt
Yes, by default it will only show the Navmesh within a certain (fairly short) radius of the view camera. To show all the Navmesh at once, right click on the top bar of your 3d window and go to View>AI Navmesh>Disable Level-of-Detail (LOD) rendering. I think the LOD thing was implemented to save on performance, but I never found that viewing the Navmesh slowed it down very much. I always have the LOD off unless I'm trying to look at just a small area and the extra Navmesh gets in the way.
Excellent! Just what I was looking for.
I guess one use for having the LOD turned on would be looking at the floor of a multi-story building where you would tend to see the navmesh of the floors below as well, otherwise...
2003MINI on 30/3/2005 at 18:10
How does one implement the affect of the oil flasks from T3? Does this require a dynamic changing of the patrol path based upon where the oil flask was thrown?