Garry's Mod

Garry's Mod

1,861 ratings
NPC Navmesh Navigation
20
11
17
4
2
7
3
5
5
8
2
6
6
4
2
3
3
3
2
2
   
Award
Favorite
Favorited
Unfavorite
Content Type: Addon
Addon Type: Tool
Addon Tags: Fun, Roleplay
File Size
Posted
Updated
109.020 KB
23 Dec, 2022 @ 10:17am
28 May, 2023 @ 4:38am
16 Change Notes ( view )

Subscribe to download
NPC Navmesh Navigation

In 1 collection by Brainless C++ Guy
[2]-Brainless-[4]'s mods
27 items
Description
This mod allows NPCs to use the navigation mesh as an alternative to AI nodes.
This means you can play on pretty much any map with NPCs.
All you need to do is ensure the map has a navmesh, If not you can use the nav_generate console command to generate one.

How It Works

The navigator will monitor all the NPCs in the game and detect if they want to move to somewhere. If the navigator detects that the NPC can't reach its destination, The navigator will then take control and try to guide the NPC to its destination using the navmesh.

Features

* Compatible with maps that have or don't have AI nodes.

* Customizable settings in the spawnmenu.

* You can disable the entire mod in one click of a button using the spawnmenu.

* NPCs can actually use dropdowns on the navmesh, Which can lead to some more advanced movement which they could not do easily with AI Nodes.

* A debug tool, ( Found in your tools section of the spawn menu ) This lets you preview the path an NPC is following VIA the navmesh.

Additional Information

* For better mod performance, Its a good idea to edit the navmesh with nav_edit 1 console command. ( Not required but encouraged )
This tool could help with that....
https://steamproxy.net/sharedfiles/filedetails/?id=527885257


* You may notice that some NPCs may be opressive when using the navmesh.
This is because without AI nodes, NPCs have slightly reduced AI behaviour.
I have done my best to override this and keep them close to their original AI behaviour as possible.

* The Navigator pathfinder prefers smaller navmesh nodes since NPCs have a better time with smaller nodes.

* If NPCs get stuck near tight spaces, You may need to tweak the navmesh slightly with nav_edit, But normaly things should be fine.

* No, This does not support VJ Base NPCs for now... Because they use a different way of marking the destination.
Yes, Support may be added in the future.

* Also keep in mind the addon is new, So there could be bugs! If you find any, Please report them. Thank you.

For Developers

Developers can call some of my global functions in their mods if they want.

-- Make an NPC move to a point using the navmesh.
Z_NPC_SetNewGoal( npc , Vector = Position )

-- Clear an NPCs navmesh movement.
Z_NPC_ClearNavigation( npc )

-- Returns the NPCs navigator destination that the NPC is trying to navigate to. ( Not the NPCs goal ) for that use NPC:GetInternalVariable( "m_vecLastPosition" )
Z_NPC_Navigator_GetNavGoal( npc )

-- Makes a waypoint for the NPC to move to, If shouldact is true, The NPC will start moving.
Z_Navigator_SetWaypoint( npc , Vector = Position , Bool = ShouldAct )

-- Marks the current waypoint an NPC is trying to get to as reached!
Z_Navigator_WaypointReached( npc )

Credits

Zenlenafelex and [2]-Brainless-[4]

If anyone wants to make an expansion on this they can, I am a bit busy trying to step away from gmod now, So i can't work on this as much.

You may and can reupload this mod to the workshop, Providing you credit ( [2]-Brainless-[4] )
Popular Discussions View All (12)
18
25 Jan @ 1:23am
PINNED: FAQ
Brainless C++ Guy
1
8 May @ 5:34pm
Npcs still jump even when i turn it off in settings
im going to defenestrate you
4
27 Dec, 2022 @ 8:40am
Are you a brain surgeon?
uncommon saucers
301 Comments
Atp Zombie 9 Jul @ 9:17am 
as for the bug which the other user mentioned:
i think it's because of the code which handles intentions, i've modified this mod to use the movement method from https://steamproxy.net/sharedfiles/filedetails/?id=313640441 (just tries to make them go towards their target using a simple calculation instead of navmesh if something goes wrong)

i tried to modify the npc ai within this mod but i realized it just isnt for that, and when playing around in the code that handles intentions, it only makes their schedule FORCED_GO_RUN if they have a target, maybe remove that check? and another bug is for melee attackers going really slow when within walkable distance but that might just be my changes, anyway, the fix for it is using IsCurrentSchedule, so as to not recall it too many times

tldr: check intentions code
Brainless C++ Guy  [author] 9 Jul @ 8:52am 
Yeah, Unfortunately its not being maintained much anymore, i would rather pass it onto someone else. but since like 39,000 people are using it. i will try to maintain it as best as possible.

i just can't really confirm or guarantee any fixes etc... like for example, i don't think that this bug is too much of a problem. but if i hear like groups of people mentioning it i will try and see if i can fix it in spare time.
otherwise i just add it to a bugs list for whenever.
Atp Zombie 9 Jul @ 7:37am 
i thought this was not maintained anymore, funny seeing op's comment from an hour ago
Brainless C++ Guy  [author] 9 Jul @ 6:38am 
ah ok, so there is something going on internally inside the code. ill take a look through the code again and see if there is any possibilities for what might be breaking. This mod could use an update anyways.
RoyTheBoy 9 Jul @ 12:42am 
no this is for all maps and i did nav edit before
Brainless C++ Guy  [author] 7 Jul @ 12:12am 
hmm, i did some testing here and it seems to work fine. that being said, it could be that the location you are testing the npcs has no navmesh nodes there. To check you can type sv_cheats 1 in console followed by nav_edit 1 and if you see loads of squares then there are navmesh nodes there and its a different problem that ill have to do some digging to find.
RoyTheBoy 6 Jul @ 9:09pm 
https://youtu.be/ClUYK4MEIDs here is a video of what happens so you can more properly understand
RoyTheBoy 6 Jul @ 5:26pm 
yeah i will go check
if its mods conflicting
but i dont really have many mods so idk
Brainless C++ Guy  [author] 6 Jul @ 6:16am 
hmm, thats a bit strange, i don't know if there could be a mod conflict going on there, or if a recent gmod update has changed something. but i will take a look at it later in spare time and see if there is anything going on.
RoyTheBoy 6 Jul @ 1:57am 
every setting is on its default