AiState
A userdata object representing an AI state belonging to a Unit.
Operations:
| Operation | Returns | Description |
|---|---|---|
AiState == AiState |
boolean | Checks if two instances of AiState are refer to the same AiState. |
Server-only
getFacingDirection
aiState:getFacingDirection( )
Returns the state's facing direction.
Parameters:
| Name | Type | Description |
|---|---|---|
state |
AiState | The state. |
Returns:
| Type | Description |
|---|---|
| Vec3 | The direction. |
getMovementDirection
aiState:getMovementDirection( )
Returns the state's movement direction.
Parameters:
| Name | Type | Description |
|---|---|---|
state |
AiState | The state. |
Returns:
| Type | Description |
|---|---|
| Vec3 | The direction. |
getMovementType
aiState:getMovementType( )
Returns a string describing the state's movement type.
Movement type can be "stand", "walk", "sprint" or "crouch".
Parameters:
| Name | Type | Description |
|---|---|---|
state |
AiState | The state. |
Returns:
| Type | Description |
|---|---|
| string | The movement type. |
getWantsCrouch
aiState:getWantsCrouch( )
Check if the state wants to crouch.
Parameters:
| Name | Type | Description |
|---|---|---|
state |
AiState | The state. |
Returns:
| Type | Description |
|---|---|
| boolean | Returns true when the state wants to crouch. |
getWantsJump
aiState:getWantsJump( )
Check if the state wants to jump.
Parameters:
| Name | Type | Description |
|---|---|---|
state |
AiState | The state. |
Returns:
| Type | Description |
|---|---|
| boolean | Returns true when the state wants to jump. |
isDone
aiState:isDone( )
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:
| Name | Type | Description |
|---|---|---|
state |
AiState | The state. |
Returns:
| Type | Description |
|---|---|
| boolean string |
Returns true when done, and a string description. |
onFixedUpdate
aiState:onFixedUpdate( deltaTime )
Updates the state by adding delta time progression.
Should be called once every game tick while the state is active.
Parameters:
| Name | Type | Description |
|---|---|---|
state |
AiState | The state. |
deltaTime |
number | The delta time. |
onUnitUpdate
aiState:onUnitUpdate( deltaTime )
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:
| Name | Type | Description |
|---|---|---|
state |
AiState | The AI state. |
deltaTime |
number | The delta time. |
start
aiState:start( )
Starts the state.
Parameters:
| Name | Type | Description |
|---|---|---|
state |
AiState | The state. |
stop
aiState:stop( )
Stops the state.
Parameters:
| Name | Type | Description |
|---|---|---|
state |
AiState | The state. |