AiState
A userdata object representing an AI state belonging to a Unit.
Functions:
- getFacingDirection
- getMovementDirection
- getMovementType
- getWantsJump
- isDone
- onFixedUpdate
- onUnitUpdate
- start
- stop
Operations:
Operation | Description |
---|---|
AiState == AiState | Checks if two instances of AiState are refer to the same AiState. |
getFacingDirection(state)
Server only
Returns the state's facing direction.
Parameters:
Type | Name | Description |
---|---|---|
AiState | state | The state. |
Returns:
Type | Description |
---|---|
Vec3 | The direction. |
getMovementDirection(state)
Server only
Returns the state's movement direction.
Parameters:
Type | Name | Description |
---|---|---|
AiState | state | The state. |
Returns:
Type | Description |
---|---|
Vec3 | The direction. |
getMovementType(state)
Server only
Returns a string describing the state's movement type.
Movement type can be "stand", "walk", "sprint" or "crouch".
Parameters:
Type | Name | Description |
---|---|---|
AiState | state | The state. |
Returns:
Type | Description |
---|---|
string | The movement type. |
getWantsJump(state)
Server only
Check if the state wants to jump.
Parameters:
Type | Name | Description |
---|---|---|
AiState | state | The state. |
Returns:
Type | Description |
---|---|
boolean | Returns 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:
Type | Name | Description |
---|---|---|
AiState | state | The state. |
Returns:
Type | Description |
---|---|
boolean, string | Returns 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:
Type | Name | Description |
---|---|---|
AiState | state | The state. |
number | deltaTime | The 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:
Type | Name | Description |
---|---|---|
AiState | state | The AI state. |
number | deltaTime | The delta time. |
start(state)
Server only
Starts the state.
Parameters:
Type | Name | Description |
---|---|---|
AiState | state | The state. |
stop(state)
Server only
Stops the state.
Parameters:
Type | Name | Description |
---|---|---|
AiState | state | The state. |