Garry's Mod

Garry's Mod

Not enough ratings
Creating/ Editing Navmeshes for Garry's Mod and Other Source Games
By Zybit
A Comprehensive guide to creating navmeshes for Garry's Mod and and any other source game; from the simple nav_generate to advanced console commands!
   
Award
Favorite
Favorited
Unfavorite
Work In Progress
This Guide is a work in progress, stay tuned for more additions.

And Happy Navmesh editing!
Use A Navmesh Editor Tool From The Workshop
To start this guide i will say one thing:
use a navmesh editor tool instead of using console commands; I will be including the console commands just in case, but i beg you to never use the majority of them. When the time comes, I will tell you which commands the tools can't do; that is when you should start using the console commands, but if the tool has the same function as the console command, use the tool.

I will be using Rubat's/ Robotboy's easy navmesh editor
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=527885257

It pretty much automatically types the console commands for you, in the form of a tool gun, instead of having to type the commands out every single time. (Your hands will thank you)

I have gone into more detail about its functions in a different section.
Types of Navmeshes
Although there are no official types of navmeshes; navmeshes can be designed for different types of nextbot. One nextbot may not work well on the same navmesh compared to another nextbot.

For example:

  • A navmesh that is made for official valve bots in counterstrike-global offensive may not work for a 2D Sanic Nextbot (also what I call a 'PNG Chaser Nextbot').

  • A navmesh designed for A PNG chaser nextbot may not work well for guess who nextbots.
and so on...

Basically, navmeshes can look very different depending on what nextbot it's designed around, and the complexity of their AI.

I will get into detail later on about how we go about making a navmesh, and how we design it around certain nextbots.
Analysis of The Easy Navmesh Editor Tool [1 of 2]
You don't have to read the entire section, if you want you can continue, but if you don't know what something means in the later sections, you can check for its definition here

Here is where i will be going over what each option on the tool bar does, and when we use them.


The alt fire button should be your 'R' key by default.

A marked node is the node which you are currently have selected and are working on, its outline will turn blue to show this.


  • attributes - attributes are used to tell nextbots what they should do once they enter a node; the most common attribute we use is crouch, which tells the nextbot to crouch when they're in the node, such as a node in a tunnel. There are many others and I will talk about them later in a different section.

  • connect - this is used to connect two nodes together, there are two different ways we can connect two nodes, bi-laterally and mono-laterally; that's just fancy talk for two way and one way connections, in other words we can tell a nextbot that they can go from one node to the other and vice versa, or they can only go one way and, can't return the same way they went; such as jumping off a ledge that you can't jump back up.

    one way connections appear as dark blue lines:



    we create a one way connection by clicking on node 1 then node 2; we are therefore telling the nextbot that they can go from node 1 to node 2, but not the other way.

    Almost every node you will see are bi-laterally connected, they appear as a cyan line connecting two nodes:



    we create a two way connection by clicking on node 1 then on node 2; and then clicking on node 2 then on node 1. Think of it like two one way connections going in either direction.

  • corner select / drop - This is used to select corners for editing with corner raise / lower, in order to select a corner you left click the node, you'll see a square appear in one of the corners, keep left clicking to select a different corner.

    Alt fire will drop all corners to ground level ( however this is affected by the corner radius variable, which i explain later in this section)

  • corner raise / lower - This is used to raise or lower the position of corners on a node; after you've selected a corner with corner select / drop, left click to raise, and alt fire to lower the corner.

  • create - this is used to manually create new nodes, to create a node you left click one corner of where you want your node to be created then left click on the other corner.







  • delete - This will delete the navmesh you are hovering over, you'll know what node you have selected as it's outline should turn yellow. Keep in mind that this will delete the node you have marked if you have one marked.

  • disconnect - this will remove all connections between two nodes; use it by clicking on one node then on the other. This will remove two way and one way connections.

  • ladder create / flip - this will create a ladder node when clicked on a ladder; this will only work on pre-existing ladders, this tool doesn't create an actual ladder if there isn't already one there, it only tells the nextbots that there is a ladder there. However, this may not work on all ladders, you will know if you can create one when the crosshair turns green.



  • mark walkable - This creates nodes which tell the navmesh generator (nav_generate) that this is an area where players can walk (in other words it tells the generator that this area, is not out of bounds).

  • merge - combines two nodes together, the nodes must have the same width or length; think of combining a square and a rectangle to create a perfect rectangle, or a rectangle and a rectangle to form a perfect rectangle,





  • splice - creates a node between two nodes and connects both of them bi-laterally to it. Used mostly to create stairs and inclines.







  • split - used to split a node into two nodes, the dividing line is seen when hovering over a node.


  • subdivide - splits a node into four different nodes, you can continue to split each of those nodes into four more, but the limit is when the created nodes are 1x1 units in size ( I will explain what this means next, in grid level).
Analysis of The Easy Navmesh Editor Tool [2 of 2]
Next up we have the variables and check boxes:

  • show light intensities - shows how intense the light is in every node; this is used by nav_analyse to find hiding spots ( I will speak more about nav_analyse later on in a different section)

  • show compass - shows the compass on the crosshair ( mind blowing)

  • show preferred areas - This should show the areas of least danger, this danger system is used by advanced ai like counter strike bots; it will usually never show anything in garry's Mod, because as far as I know, no nextbots use this system.

  • show areas to avoid - Also part of the danger system, used to show areas of most danger and so these areas should be avoided; mostly useless in gmod anyway.


  • snap cursor's Z position to the Z position of the player - used to move the cursor / crosshair to the same level as the player's feet, useful when you need to over-extend a node over an edge or dealing with weird physics hitboxes.


    Now For Variables:

  • snap to grid level - used to keep the cursor to a grid of length:

    0 - No grid at all, highly do not recommend using EVER

    1 - snap to grid level 1x1, the grid level nav_generate uses and the smallest all console
    functions will go (example, subdivide).

    2 - snap to grid level 0.20 x 0.20, used for making nodes flush with each other, but while also having a bit more accuracy than grid level 1.

    3 - snap to grid level 0.04 x 0.04, used to make extremely precise nodes, such as on railings or on thin platforms above the ground.

  • area info display time - how long the name of a node as well as how many connections it has, should appear when hovered over with the cursor; the name of a node is used mainly by counter-strike bots to know what location they are in for callouts But functionally useless in Garry's Mod

  • corner radius - this variable controls the distance -in units- that nearby nodes's corners are affected by the corner raise/lower or node drop to ground tool (e.g: if corner radius is 0; only the corner that is clicked on will move, no other corners of any other nodes will move to fill the gap that is created between the nodes).

    Setting this variable really high can be used to drop a huge amount of nodes to the ground; be warned though this can be dangerous to do, you could lose progress.

  • compress nav area ids - this will make sure that there are no gaps in nav area ids, you can see nav ids when hovering your cursor over a node. (e.g: there are two nav areas, #9 and nav area #11, there is a gap, we are missing #10, compressing these will lead to nav area #9 and nav area #10; there is now no gap because we've changed #11 to #10.

    We are now in the so-called danger zone! these are settings related to nav_generate.

  • quicker but worse generation - this enables nav_quicksave 1, this skips a portion of the analysing; it means that when it analyses after it generated the navmesh, it won't check for encounter spots or sniper spots.

    You can enable this to get your navmesh generated first, edit it, and then type nav_analyse in console to get the full analyse before publishing it or adding the mesh to your map.

  • create a new navigation mesh - literally types nav_generate in the console.

  • clear all nav areas - deletes all nodes on the map; however it does not save afterwards, which means if you run the next command, it will bring back the mesh that you saved.

  • reload the navigation mesh - reloads your navmesh for your map, saved in your gmod maps folder. (Steam\steamapps\common\GarrysMod\garrysmod\maps)

  • save changes - does what it says, it saves your progress to a file with the name: [mapname].nav into your gmod maps folder. (Steam\steamapps\common\GarrysMod\garrysmod\maps)

And those are all the features of the Easy Nav Mesh Editor, well done if you read the whole thing. Now we're going to go onto the 'fun' bits, actually making the mesh.
Generating a Navmesh using nav_generate.
Everyone and their mother knows about nav_generate, but there are a few things you'll want to know before actually running that command.

For this section i will be deleting gm_contstruct's navmesh and creating my own, generated one.

What does nav_generate do and how does it work?

nav_generate samples all walkable space starting from the player spawnpoints, and creates meshes along the way.

One of the problems nav_generate encounters, is when areas can't be reached on foot, such as roofs and areas reached from the dreaded... teleporters.

We'll see that there won't be any nav meshes in these areas if we just type nav_generate and don't do anything else.

We can solve this problem by telling the generator that some areas it thinks are unreachable, are actually walkable; We do this by creating walkable marks; type nav_mark_walkable into the console when pointing at a floor.

The generator will search for more walkable areas outwards from these marks.







We keep adding these marks to places that we suspect the generator may not think players can walk on, such as roofs, above ladders and in places parkour is need to get to; we don't have to worry about adding walkable nodes inside buildings, the generator will go through doors.

The generator will get most areas on a map, so you won't need to add too many walkable marks.

By default, the generator should go up walls as far as a player can fall without taking damage.

(many of the generator's variables can be configured with console commands, but that is advanced and perhaps for a later section.)

Once you've added your walkable areas, you can now type nav_generate in the console.
This can take quite some time, so be patient, even if it's unresponsive; as long as it hasn't quit the application fully, it's working.

The length that it should take to generate will depend of these factors:

- how powerful your computer is; it will use RAM and CPU the most.
- how large the map is; should go without saying but: the bigger the map, the longer it will take.
- this is one thing most people don't know; how open the map is, the more wide-open the map is, the longer the process -computing navmesh visibilty- will take,
- Whether garry's mod is in x86 or x64 bit (You can look up how to do this if you haven't already); you want it to be in x64, the game can use more of your available processing power.

Once the mesh is done processing we can move on to the next section.
Editing The Generated Navmesh, and The Problems We Should Look Out For.
Now that we have a generated navmesh, we can start editing it to make it better.

these are the first things we look out for (non-optional for a functioning navmesh):

  • Areas without a navmesh; if we find an area without a navmesh we should place down a walkable mark. Once we've done that to all the areas missing a navmesh, we type nav_generate_incremental into the console; it is very important that we type nav_generate_incremental and not nav_generate, nav_generate will delete the entire navmesh and start generating from the beginning; the incremental version on the other hand, will keep the existing navmesh and generate new areas in the places with walkable marks.

  • Areas not connected to other areas; an example being one room not connected to another room through a doorway. We can fix these by creating a node in the doorway between the meshes (i'll use gm_realpark_final3 as an example).

    We can do this with the create tool in the easy navmesh editor, ( if you don't know what that is, or how to use it, see near the beginning of analysis of the easy navmesh editor section) we create a section between the meshes, inside the doorway, and then we connect this newly created node with a two-way connection to both sides.




    You can find these areas by looking around or by spawning a nextbot and have it follow / chase you, if it turns around and goes a different way other than the direct way to you, check if there's no connections.

    That's the end of the non-optional fixes, right now you should have a better navmesh than if you just typed nav_generate, you could end it here, but there are still alot of things you can do to make it perfect.
How To Publish A Navmesh
[This Section is for a final, completed navmesh, this guide has not gone over how to perfect your navmesh, so please beware that whatever navmeshes you publish now, may not be as good as they can be.]

So you've completed your navmesh? And you want others to be able to use it and download it from the workshop? Well here you go:

I want to say one thing first: you should use gmpublisher; you don't have to use it, but it will make publishing to the workshop and updating, so much easier than if you did it manually ( I will not be going over in this guide how to do it manually, but it should be the same steps as publishing other addons in the tutorials, just keep the navmesh inside of the maps folder).


1. First you want to install gmpublisher

2. Save your completed navmesh, either with the navmesh editor tool or by typing nav_save into the console.

3. Go to your Garrys mod directory, it should look something like this:
C:\Program Files (x86)\Steam\steamapps\common\GarrysMod\garrysmod\maps

4. You should see a file with the map name ending in .nav ( example: gm_construct.nav ), copy it.

5. Create a folder on your desktop, or anywhere you want your addon saved, it can be any name but you should probably name it something to do with your addon so you'll know what it is ( example: Construct Navmesh )

6. Inside of this created folder. create a new folder; this must be named maps, exactly, lowercase as well, this will tell the game where your addon's file should be put, in this case it tells it to put the navmesh into the maps folder. (example Construct Navmesh\maps\ )

7. Paste your .nav file into the maps folder.

8. Open gmpublisher and go to 'My Workshop' and click 'publish new'.





9. Where it says browse, is where you'll put your thumbnail for your addon. It says 1 MB max; you can reduce the size of your file, (on windows) by opening the picture with the windows photos app, clicking the 3 dots, clicking resize and then clicking 'best for profile pictures and thumbnails'.

10. Addon path is where your addon folder is, you can click the file icon next to addon path to find and select the addon folder. Make sure that when you click 'select folder' you are inside the addon folder and not the maps folder. You'll know you've done it right when under the 'file browser' area, it shows a folder called maps.

11. Type and tags are self-explanatory, just put whatever tags you feel best describes the use of your navmesh; I recommend putting your addon's type, as map.

12. This is how you replace a navmesh for a map that already comes with a navmesh, under ignored file patterns type " .db ", without the quotes; you don't have to do this if the map doesn't come with a navmesh already. By doing this, when someone downloads your navmesh, your navmesh will replace the existing navmesh for the map.

13. When you're done, click publish; once it's finished uploading, your navmesh should now be on the workshop but it is private and only you can see it for now, you should try to add pictures and a description to it, there should be plenty of tutorials, if you can't figure out how to.

14. Once you've put you're finishing touches onto the addon description and pictures, go to the visibility settings on the right, set the visibility to public instead of private and then now your addon is visible on the workshop to everyone.

Bonus part:
How do i add gifs to my addon?
A gif must be 2MB or under to upload; in order to reduce the size of a gif you can try going onto ezgif.com and reducing the size of the gif there, but not by too much; we still need to see it, maybe
make it 25 to 50% of its original size. If it's still not under 2MB you can optimize it, you can do this on ezgif.com again. In the optimize image section, you'll see a slider that says "compression level", try to keep it low, but increase it just enough until the gif is under 2MB; once you've done that, save the image; you can now upload the gif to your addon page.

Work In Progress
This Guide is a work in progress, stay tuned for more additions.

And Happy Navmesh editing!
6 Comments
Ликус 15 Jul @ 10:33pm 
I want to generate a navmesh for Danger Zone maps in CS:GO. Do you know how to do it?
bunabyte 6 Nov, 2022 @ 2:01pm 
Okay, that makes sense. I'll do that next time I'm making a map.
Zybit  [author] 5 Nov, 2022 @ 6:03pm 
-"in the same file"
In the same folder, i meant.
Zybit  [author] 5 Nov, 2022 @ 6:02pm 
@AcinonX, You can add the generated navmesh into the folder with your map, the navmesh is always in the same folder as the actual map.

So when you're uploading the map to the workshop, just upload the map with the navmesh in the same file.
Zybit  [author] 5 Nov, 2022 @ 3:08pm 
@AcinonX, I'm not sure that there is a way to generate a navmesh before compiling a map in hammer; you have to compile the map, then go into Gmod and generate the navmesh from there.

You only really generate a navmesh after you're finished a map anyway; or i guess if you want to test nextbots on the map, in which case you'll have to generate it afterwards as well.
bunabyte 5 Nov, 2022 @ 1:42pm 
But how do I do this when editing my map? It shows you how to do it in-game, but I don't know how to generate navmeshes before compiling and uploading my maps.