Garry's Mod Wiki


NextBots are a new system to create NPCs in the Source Engine, utilizing the more powerful navmesh system for navigation over the old node based system.

This page lists all possible functions usable with NextBots.

See NextBot NPC Creation for more information on how to create NextBot NPCs.


Entity NextBot:BecomeRagdoll( CTakeDamageInfo info )
Become a ragdoll and remove the entity.
Should only be called in BodyUpdate. This sets the move_x and move_y pose parameters of the bot to fit how they're currently moving, sets the animation speed to suit the ground speed, and calls FrameAdvance. This function might cause crashes with some activities.
Vector NextBot:FindSpot( string type, table options )
Like NextBot:FindSpots but only returns a vector.
table NextBot:FindSpots( table specs )
Returns a table of hiding spots.
number NextBot:GetActivity()
Returns the currently running activity
number NextBot:GetRangeSquaredTo( Vector to )
Returns squared distance to an entity or a position. See also NextBot:GetRangeTo.
number NextBot:GetRangeTo( Vector to )
Returns the distance to an entity or position. See also NextBot:GetRangeSquaredTo.
number NextBot:GetSolidMask()
Returns the solid mask for given NextBot.
Called from Lua when the NPC is stuck. This should only be called from the behaviour coroutine - so if you want to override this function and do something special that yields - then go for it. You should always call self.loco:ClearStuck() in this function to reset the stuck status - so it knows it's unstuck. See CLuaLocomotion:ClearStuck.
string NextBot:MoveToPos( Vector pos, table options )
To be called in the behaviour coroutine only! Will yield until the bot has reached the goal or is stuck
NextBot:PlaySequenceAndWait( string name, number speed = 1 )
To be called in the behaviour coroutine only! Plays an animation sequence and waits for it to end before returning.
NextBot:SetSolidMask( number mask )
Sets the solid mask for given NextBot. The default solid mask of a NextBot is MASK_NPCSOLID.
NextBot:StartActivity( number activity )
Start doing an activity (animation)

Page Links

Special Pages



Render Time: 31ms

Session 0
DB GetPage 3
Generate Html 6
SaveChanges 10
Render Body 0
Render Sidebar 10