AiState

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

Functions:

Operations:

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

getFacingDirection(state)

Server only

Returns the state's facing direction.

Parameters:

TypeNameDescription
AiStatestateThe state.

Returns:

TypeDescription
Vec3The direction.

getMovementDirection(state)

Server only

Returns the state's movement direction.

Parameters:

TypeNameDescription
AiStatestateThe state.

Returns:

TypeDescription
Vec3The direction.

getMovementType(state)

Server only

Returns a string describing the state's movement type.

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

Parameters:

TypeNameDescription
AiStatestateThe state.

Returns:

TypeDescription
stringThe movement type.

getWantsJump(state)

Server only

Check if the state wants to jump.

Parameters:

TypeNameDescription
AiStatestateThe state.

Returns:

TypeDescription
booleanReturns true when the state wants to jump.

isDone(state)

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:

TypeNameDescription
AiStatestateThe state.

Returns:

TypeDescription
boolean, stringReturns true when done, and a string description.

onFixedUpdate(state, deltaTime)

Server only

Updates the state by adding delta time progression.

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

Parameters:

TypeNameDescription
AiStatestateThe state.
numberdeltaTimeThe delta time.

onUnitUpdate(state, deltaTime)

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:

TypeNameDescription
AiStatestateThe AI state.
numberdeltaTimeThe delta time.

start(state)

Server only

Starts the state.

Parameters:

TypeNameDescription
AiStatestateThe state.

stop(state)

Server only

Stops the state.

Parameters:

TypeNameDescription
AiStatestateThe state.