Version:

Simple State Component

The Simple State component provides a simple state machine. Each state is represented by a name and an array of zero or more entities. The entities are activated upon entering the state and deactivated upon exiting it. A simple state component may be in NullState, which means no state is active.

Provider

O3DE Core (LmbrCentral) Gem

Simple State properties

Simple State component properties

PropertyDescriptionValuesDefault
Initial stateThe active state when the Simple State component is first activated.<None> or state Name<None>
Reset on activateIf enabled, Simple State component returns to the Initial state when activated, and not the state held before deactivating.BooleanEnabled
StatesAn array of states.
States - NameDefines the name of the state.StringNew State
States - EntitiesAn array of entities that are associated with a state.EntityIdNone

SimpleStateComponentRequestBus

Request NameDescriptionParameterReturnScriptable
GetCurrentStateReturns the Name of the current state.NoneState: StringYes
GetNumStatesReturns the total number of states.NoneCount: IntegerYes
SetStateSets the component to a specific state by Name.State: StringNoneYes
SetStateByIndexSets the component to a specific state by its index in the States array.State Index: IntegerNoneYes
SetToFirstStateSets the component to State[0], the first state in the States array.NoneNoneYes
SetToLastStateSets the component to the last state in the States array.NoneNoneYes
SetToNextStateSets the component to the next state in the States array.NoneNoneYes
SetToPreviousStateSets the component to the previous state in the States array.NoneNoneYes

SimpleStateComponentNotificationBus

Notification NameDescriptionParameterReturnScriptable
OnStateChangedNotifies listeners that the state has changed.NoneOld State: String, New State: StringYes

For more information, see Working with the Event Bus (EBus) system.