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.

Arguments:
Returns:

getMovementDirection

AiState:getMovementDirection()
Server-Only

Returns the state's movement direction.

Arguments:
Returns:

getMovementType

AiState:getMovementType()
Server-Only

Returns a string describing the state's movement type.

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

Arguments:
Returns:
  • [ string ]: The movement type.

getWantsJump

AiState:getWantsJump()
Server-Only

Check if the state wants to jump.

Arguments:
Returns:
  • [ bool ]: 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.

Arguments:
Returns:
  • [ bool ]: 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.

Arguments:
  • 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.

Arguments:
  • AiState [ AiState ]: The state.
  • dt [ number ]: The delta time.

start

AiState:start()
Server-Only

Starts the state.

Arguments:

stop

AiState:stop()
Server-Only

Stops the state.

Arguments: