Garry's Mod Wiki

NPC:SetLastPosition

  NPC:SetLastPosition( Vector Position )

Description

Sets the last registered or memorized position for an npc. When using scheduling, the NPC will focus on navigating to the last position via nodes.

The navigation requires ground nodes to function properly, otherwise the NPC could only navigate in a small area. (https://developer.valvesoftware.com/wiki/Info_node)

Arguments

1 Vector Position
Where the NPC's last position will be set.

Example

Make an NPC chase a player

function NPCGoGoRun(npc, ply) npc:SetLastPosition( ply:GetPos() ) npc:SetSchedule( SCHED_FORCED_GO_RUN ) end
Output: The NPC will chase the player.