gm_navigation makes navigation tasks a breeze.
This all in one navigation module lets you easily create a node table that you can use for finding paths using a A* path finding algorithm.
All the other navigation modules currently available were too laggy for my needs. I have profiled this code and found it far more superior than the lua versions.
Functions
nav.CreateNav((number)gridsize) -- Returns a new Nav with a set grid size Nav:GetNodeByID(number) -- Returns the node with the given ID Nav:GetNodes() -- Returns a table with all the nodes Nav:GetNodeTotal() -- Returns the number of total nodes Nav:StartGeneration() -- Start generating nodes, used to setup variables Nav:AddGroundSeed(Pos, Normal) -- Adds a walkable seed. During navigation the node will start spreading out from the first walkable seed. Once that seed is used up it will go on to the second, third and so on. The module will account for seed overlapping. Nav:AddAirSeed(Pos) -- Adds a seed for air nav generation (Similar to AirGroundSeed, but it will make air nodes). Nav:ClearGroundSeeds() -- Simply removes all ground seeds Nav:ClearAirSeeds() -- Simply removes all ground seeds Nav:SetupMaxDistance(position, (number)distance) -- Confines all the generated nodes to a set vector within the specified distance Nav:Generate(function(Nav) print("Finished Generating") end [[, function(Nav, GeneratedNodeCount) print("Generating", Nav, "Nodes Generated:", GeneratedNodeCount) end]] ) -- Generates the node graph (threaded), will call the first callback function once it finishes. The optional second argument will be called while the nav is being generated every second. This function returns true if it was successfully added to the thread queue. Nav:FullGeneration() -- Generates the node graph (Non threaded), returns the amount of seconds it took to generate. Nav:IsGenerated() -- Returns a bool based on if its generated or not Nav:FindPath(function(Nav, FoundPath, Path) end) -- Finds a path from the start to the end node (Specified from Nav:SetStart / End). The callback function is passed the nav it was called on, boolean FoundPath (true a path was found), and a path table that contains a series of nodes the path took from start to end. The optional second argument will be called while the nav is being generated every second. This function returns true if it was successfully added to the thread queue. Nav:FindPathHull(mins, maxs, function(Nav, FoundPath, Path) end) -- Similar to FindPath but this will trace the specified hull along the path to ensure there is room for something with the hull size to move along it. It's useful if you are moving an entity along a path that might have entities / the level blocking it. Mins, and maxs are vectors for the hull size. This function returns true if it was successfully added to the thread queue. Nav:GetHeuristic() -- Returns an heuristic enumeration Nav:GetStart() -- Returns the starting node Nav:GetEnd() -- Returns the ending node Nav:SetHeuristic(HEURISTIC_BLAH) -- Put one of those fun heuristic enum's here Nav:SetStart(Node) -- Set the start node for FindPath Nav:SetEnd(Node) -- Set the endnode for FindPath Nav:GetNode(position) -- Returns the node at the position (Can be off by GridSize * 0.45) Nav:GetClosestNode(position) -- Returns the closest node to said position Nav:GetNodesInSphere(pos, radius) -- Returns a table of nodes found within the radius of the pos Nav:GetDiagonal() -- Returns a boolean for diagonal linking Nav:SetDiagonal(bool) -- Used to enable / disable diagonal linking Nav:GetGridSize() -- Returns grid size (number) Nav:SetGridSize(number) -- Set the grid size (Space between the nodes) Nav:GetMask() -- Returns the trace mask used during the node generation Nav:SetMask(MASK_*) -- Set the trace mask Nav:CreateNode(Pos, Normal) -- Returns a new node at position Pos and normal Normal Nav:RemoveNode(node) -- Removes node from existence Nav:Save(filename) -- Saves the Nav to a file Nav:Load(filename) -- Load the Nav from a file Node:GetID() -- Returns the id of the node in the GetNodes table. Useful for comparing nodes Node:GetPosition() -- Returns vector of the nodes position Node:GetPos() -- Alias of Node:GetPosition() Node:GetNormal() -- Returns vector of the nodes normal Node:GetConnections() -- Returns node table of the nodes connections Node:IsConnected(OtherNode) -- Returns a bool if Node is connected to OtherNode Node:SetPosition(Pos) -- Change the nodes position Node:SetNormal(Normal) -- Change the nodes normal Node:ConnectTo(Node2, Dir) -- Link Node to Node2 in direction Dir Node:RemoveConnection(Dir) -- Removes connection in the direction Dir
Enumerations
nav.NORTH nav.SOUTH nav.EAST nav.WEST nav.NORTHEAST nav.NORTHWEST nav.SOUTHEAST nav.SOUTHWEST nav.UP nav.DOWN nav.LEFT nav.RIGHT nav.FORWARD nav.BACKWARD nav.NUM_DIRECTIONS nav.NUM_DIRECTIONS_DIAGONAL nav.NUM_DIRECTIONS_MAX nav.HEURISTIC_MANHATTAN nav.HEURISTIC_EUCLIDEAN
Example File
Example file should be used clientside so you can see what your doing.
Put it in your autorun directory and type "snav_generate_ground" to generate some ground nodes.
snav_generate_air to generate air nodes
snav_generate_ground_air to generate ground and air nodes.
Hold alt to view the nodes.
Go near a node and type "snav_setstart"
Go near another node and type "snav_setend"
Hold shift to view the path.
Download
Source: http://spacetechmodules.googlecode.c.../gm_navigation
Windows:
Client: http://spacetechmodules.googlecode.c...tion_win32.dll
Server: http://spacetechmodules.googlecode.c...tion_win32.dll
The example file will make a fun picture like this
gm_construct with 64 grid size, generated in 15 seconds with diagonal linking enabled. Node Total: 8092, Link Total: 58746 (Sorry for horrible quality)
Demonstration of Nav:FindPathHull with a hull about the size of a player.
Ground and air nodes:
![]()

Register
Events
Popular
More
Post #1








x 22
x 11
x 4
x 2
x 2
x 1
x 1
Agree x 4



Disagree x 1



Informative x 1

