Skip to main content

AiState

A userdata object representing an AI state belonging to a Unit.

This library can only be used on the server.

Operations:

OperationDescription
AiState == AiStateChecks if two instances of AiState refer to the same AiState.

functions

getFacingDirection

AiState:getFacingDirection()

Server-Only

Returns the state's facing direction.

Parameters:

Returns:

  • (Vec3): The direction.

getMovementDirection

AiState:getMovementDirection()

Server-Only

Returns the state's movement direction.

Parameters:

Returns:

  • (Vec3): The direction.

getMovementType

AiState:getMovementType()

Server-Only

Returns a string describing the state's movement type.

Movement type can be "stand", "walk", "sprint" or "crouch".

Parameters:

Returns:

  • (string): The movement type.

getWantsJump

AiState:getWantsJump()

Server-Only

Check if the state wants to jump.

Parameters:

Returns:

  • (boolean): True when the state wants to jump.

isDone

AiState:isDone()

Server-Only

Checks if the AI state is done.

Returns true when the state is done, and a string describing the state's current situation.

Can be used to determine if another state is allowed to be started.

Parameters:

Returns:

  • (boolean): True if the state is done.
  • (string): The state's current situation.

onFixedUpdate

AiState:onFixedUpdate( dt )

Server-Only

Updates the state by adding delta time progression.

Should be called once every game tick while the state is active.

Parameters:

  • AiState (AiState): The state.
  • dt (number): The delta time.

onUnitUpdate

AiState:onUnitUpdate( dt )

Server-Only

Updates the state by adding delta time progression.

Should be called once every unit update, by the unit that owns the state, while the state is active.

Parameters:

  • AiState (AiState): The state.
  • dt (number): The delta time.

start

AiState:start()

Server-Only

Starts the state.

Parameters:


stop

AiState:stop()

Server-Only

Stops the state.

Parameters: