How to properly make and edit navmesh - T-Rizzle12/Custom-Gmod-Bot GitHub Wiki
There are three ways to create a navmesh.
- You hand make the mesh, this is the slowest, but most well made kind of navmesh.
- You can generate the navmesh using
sv_cheats 1thennav_generateinto the console, this is faster and more efficient, but tends to make mistakes and very rarely can miss certain areas.- If
nav_generatemisses an area go to said area look at it, enternav_mark_walkablethen enternav_generate_incrementalinto the console. This will tell the navmesh generator to fill in the missing areas without deleting areas that have already been created.
- If
- When you incrementally generate the mesh, you can save time as apposed to hand making the mesh, but
nav_generate_incrementalis slower thannav_generate.nav_generate_incrementalis easier for computers that tend to crash when usingnav_generate. Keep doing this until the entire map has navmesh.
After you finish creating the mesh you can use it immediately, (Unless you made the mesh by hand then you need to run nav_analyze first), but most of the time the mesh will have errors in it. The rest of this guide will show and explain how to recognize and fix these errors. This guide will also show you how to use navmesh attributes to make most bots move more efficiently and control bot behavior.
Make sure that nav_edit is set to 1. You can tell it’s on if a white cursor appears where you character is looking at or if you see the nav_areas. There are a few things you should know. There are two types of connections: one way, “dark blue lines,” and bi-directional, “light blue lines”. The names are self explanatory and they tells the bots what direction they can travel between each areas.
There are also green and pink lines, these are hiding and sniper spots. Green lines are hiding spots and tell bots this a great area to hide in, (The green lines can also show "semi-exposed" hiding spots that bots will rarely use) The pink lines are "exposed" hiding spots and tell the bots where not to hide.
There are also nav attributes. You can tell what attribute is applied to an area by looking at the shape on the area, (It should also be labeled with the attribute as well.) Some bots can only take certain attributes into account when pathfinding.
Here are the attributes you can use and find on the mesh:
- Jump: green X, tells bots to jump in order to reach a higher connected area and that this area is not usable as a hiding/sniper spot
- Crouch: blue diagonal slash, forces bots to crouch when moving through this area, needed to make bots traverse vents or small holes correctly
- No Jump: red rhombus, forces bots not to jump and is useful to stop bots from excessively jumping, However bots can get stuck if jumping is required to keep going
- Precise: green +, prevents bots from skipping this area and stops bots form avoiding obstacles. The precise attribute can help in places where bots can easily fall of, like catwalks with no railings or when setting up specific routes for a jump
- Stop: red octagon, tells bots to stand still for a short moment when entering this areas. Useful to slow bots down to line up tricky jumps more accurately
- Run: two blue arrows, tells bots explicitly run in this area
- Walk: one green arrow, tells bots explicitly walk silently in this area
- Avoid: two red triangles, tells bots not to use the area unless the normal route has become to dangerous
- Don’t Hide: tells
nav_analyzenot to create hiding spots here, great for stopping the bots from hiding in the open because the engine said it was a great hiding spot - Stand: tells bots not to crouch while hiding in the area
- No hostages: tells hostage NPC’s not to use this areas
- Transient: dashed outline, tells bots the area could potentially become blocked later and should be check periodically
- Blocked: blue rectangle, tells bot not to use this area. This attribute is only set automatically by the game in certain cases when bots can’t or shouldn’t use a nav_area. Examples include:
func_nav_blockerentities, closedfunc_doorentities, and lockedprop_door_rotatingentities. - Stairs: green lines, used to tell bots not to jump and not to climb on it. Makes the bot walk properly up and down stairs/ramps.