Garry's Mod Wiki

NPC:AdvancePath

  NPC:AdvancePath()

Description

Advances the NPC on its path to the next waypoint.

Calling this on an NPC without any route will result in an instant crash.

Example

Make your scripted NPC advance to the next waypoint without exactly having to step on the node, making it advance when the NPC's hull is nearby.

function ENT:OverrideMode(flInterval) local vecCurWaypoint = self:GetCurWaypointPos() if !vecCurWaypoint:IsZero() then local threshold = self:BoundingRadius() or 1 local curDistance = self:GetPos():Distance(vecCurWaypoint) if curDistance < threshold then if !self:GetNextWaypointPos():IsZero() then self:AdvancePath() else self:ClearGoal() self:OnMovementComplete() end end end end