Garry's Mod Wiki

navmesh

The navigation mesh library. To be used with CNavArea.

The navigation mesh is used by NextBot to calculate path to its target.

Methods

navmesh.AddWalkableSeed( Vector pos, Vector dir )
Add this position and normal to the list of walkable positions, used before map generation with navmesh. BeginGeneration
navmesh.BeginGeneration()
Starts the generation of a new navmesh. This process is highly resource intensive and it's not wise to use during normal gameplay
Clears all the walkable positions, used before calling navmesh. BeginGeneration.
CNavArea navmesh.CreateNavArea( Vector corner, Vector opposite_corner )
Creates a new CNavArea.
CNavLadder navmesh.CreateNavLadder( Vector top, Vector bottom, number width, Vector dir, number maxHeightAboveTopArea = 0 )
Creates a new CNavLadder.
table navmesh.Find( Vector pos, number radius, number stepHeight, number dropHeight )
Returns a list of areas within distance, used to find hiding spots by NextBots for example.
table navmesh.FindInBox( Vector pos1, Vector pos2 )
Returns a list of CNavAreas overlapping the given cube extents.
Returns an integer indexed table of all CNavAreas on the current map. If the map doesn't have a navmesh generated then this will return an empty table.
Returns a table of all blocked CNavAreas on the current map. See CNavArea:MarkAsBlocked.
Returns the position of the edit cursor when nav_edit is set to 1.
Finds the closest standable ground at, above, or below the provided position. The ground must have at least 32 units of empty space above it to be considered by this function, unless 16 layers are tested without finding valid ground.
Returns the currently marked CNavArea, for use with editing console commands.
Returns the currently marked CNavLadder, for use with editing console commands.
CNavArea navmesh.GetNavArea( Vector pos, number beneathLimit )
Returns the Nav Area contained in this position that also satisfies the elevation limit. This function will properly see blocked CNavAreas. See navmesh. GetNearestNavArea.
Returns a CNavArea by the given ID. Avoid calling this function every frame, as internally it does a lookup trough all the CNavAreas, call this once and store the result
Returns the total count of nav areas on the map. If you want to get all nav areas, use navmesh. GetAllNavAreas instead as nav areas IDs are not always sequential.
Returns a CNavLadder by the given ID.
CNavArea navmesh.GetNearestNavArea( Vector pos, boolean anyZ = false, number maxDist = 10000, boolean checkLOS = false, boolean checkGround = true, number team = TEAM_ANY=-2 )
Returns the closest CNavArea to given position at the same height, or beneath it. This function will ignore blocked CNavAreas. See navmesh. GetNavArea for a function that does see blocked areas.
Returns the classname of the player spawn entity.
Whether we're currently generating a new navmesh with navmesh. BeginGeneration.
boolean navmesh.IsLoaded()
Returns true if a navmesh has been loaded when loading the map.
navmesh.Load()
Loads a new navmesh from the . nav file for current map discarding any changes made to the navmesh previously. Calling this function too soon, causes the Server to crash!
navmesh.Reset()
Deletes every CNavArea and CNavLadder on the map without saving the changes.
navmesh.Save()
Saves any changes made to navmesh to the . nav file.
navmesh.SetMarkedArea( CNavArea area )
Sets the CNavArea as marked, so it can be used with editing console commands.
navmesh.SetMarkedLadder( CNavLadder area )
Sets the CNavLadder as marked, so it can be used with editing console commands.
navmesh.SetPlayerSpawnName( string spawnPointClass )
Sets the classname of the default spawn point entity, used before generating a new navmesh with navmesh. BeginGeneration.