Skip to main content

MoveType, MoveStyle and LookType

These tables control how an NPC moves and looks around: MoveType is its speed (walk, run, sprint, stand), MoveStyle is the attitude it moves with (normal, searching, patrolling, nervous, ...), and LookType is whether it turns only its head or its whole body to look at something.

Available on: Server, Client (the tables exist on both sides, but only the server's NPC methods take them)

Values​

MoveType​

How fast the NPC moves.

Used by (see NPCHandle, server):

  • npc:Move(direction, moveType, moveStyle)
  • npc:Follow(target, moveType, moveStyle)

A value outside 0..3 raises the Lua error invalid move type <n>.

NameValueMeaning
MoveType.Walk0Walk.
MoveType.Run1Run.
MoveType.Sprint2Sprint.
MoveType.Idle3Stand still.

MoveStyle​

The attitude the NPC moves with, which changes its movement animations.

Used by (see NPCHandle, server):

  • npc:Move(direction, moveType, moveStyle)
  • npc:Follow(target, moveType, moveStyle)

A value outside 0..5 raises the Lua error invalid move style <n>.

NameValueMeaning
MoveStyle.Normal0Normal movement.
MoveStyle.Search1Searching, looking around for something.
MoveStyle.NervousBackoff2Nervously backing off.
MoveStyle.Patrol3Patrolling.
MoveStyle.Concerned4Concerned, on alert.
MoveStyle.NervousWalk5Walking nervously.

LookType​

What the NPC turns to look at a position.

Used by npc:LookAt(position, lookType) (server). A value outside 0..1 raises the Lua error invalid look type <n>.

NameValueMeaning
LookType.Head0Turn only the head.
LookType.Body1Turn the whole body.

Example

-- server: spawn a guard that patrols after a random player, then stops and looks at them
local position = vec3(2851.6, 541.1, -9920.1)
local guard = World.SpawnNPC("ghost_enemy_001", position)

local target = World.GetRandomPlayer()

if target then
guard:Follow(target, MoveType.Walk, MoveStyle.Patrol)

Timer.Set(function()
guard:Move(vec3(0, 0, 0), MoveType.Idle, MoveStyle.Normal)
guard:LookAt(target:GetPosition(), LookType.Body)
end, 10000, 1)
end