Skip to main content

sm.unit

Associated object type: Unit

An AI Unit performs the AI, pathfinding and logic needed for NPC behavior.
A Unit controls a Character in the world.
This library exists only on the server.

Functions

createUnit

local unit = sm.unit.createUnit(uuid, feetPos, yaw, data, pitch)

Server-Only

Creates a new Unit.

Parameters:

  • uuid (Uuid): The character type uuid.
  • feetPos (Vec3): The feet position of the unit, at the spawn position.
  • yaw (number, optional): The initial yaw. Defaults to 0.
  • data (any, optional): Extra parameters passed to the unit script.
  • pitch (number, optional): The initial pitch. Defaults to 0.

Returns:

  • unit (Unit): The created unit.

getAllUnits

local units = sm.unit.getAllUnits()

Server-Only

Returns an array of all Units in the world.

Returns:

  • units (table): The array of units.