UGantryInitStateComponent
A component that readies one feature of an actor in steps, through the Game Framework Component Manager's init states, and can be made in Blueprint.
Use it when part of an actor needs other things first. A pawn's inventory, for example, may need its data asset loaded and its player state replicated before it can be used. Each step waits until Can Change Init State says the feature may move on: its data has loaded, the player state has replicated, or another feature on the actor has got far enough.
The component tries again whenever any other feature on the actor changes state, and whenever you call Check Init State, for example after something it was waiting on arrives. On Init State Changed runs at each step, so you do that step's work there.
Init States is the chain of steps, in order. It starts as the four InitState tags: InitState.Spawned, InitState.DataAvailable, InitState.DataInitialized and InitState.GameplayReady. Replace them with your game's own tags if they differ. The chain is registered with the component manager when the component registers.
Gantry never moves an actor through the chain itself. Each feature advances as far as its own conditions allow. Other code waits for a feature with Wait For Init State or Has Reached Init State.
In Blueprint
Make a Blueprint subclass, add it to an actor, and implement Can Change Init State and On Init State Changed. Implement On Other Feature Changed to react to the actor's other features.
In C++
Override K2_CanChangeInitState_Implementation to decide each step, and HandleChangeInitState to do its work. Your module needs ModularGameplay among its dependencies, because the interface underneath (IGameFrameworkInitStateInterface) lives there.
- Inherits
UActorComponent- Implements
IGameFrameworkInitStateInterface
Properties
| Property | Type | Default | Description |
|---|---|---|---|
FeatureName read-only | FName | None | The feature's name with the component manager; the class name when empty. Other features and Wait For Init State name it by this. |
InitStates read-only | TArray<FGameplayTag> | The chain of states, in order. |
Functions
CheckInitState
Tries to move along the chain as far as Can Change Init State allows.
Call it when something the feature waits on has arrived.
K2_CanChangeInitState
Whether the feature may move from one state to the next.
The default allows every step.
| Pin | Type | Direction | Description |
|---|---|---|---|
CurrentState | FGameplayTag | in | The state it is in (empty before the first). |
DesiredState | FGameplayTag | in | The next state in the chain. |
| Return Value | bool | out | True to move on. |
K2_HasReachedInitState
Whether the feature has reached a state, or one after it.
| Pin | Type | Direction | Description |
|---|---|---|---|
State | FGameplayTag | in | A state in the chain. |
| Return Value | bool | out | True once reached. |
K2_OnInitStateChanged
The feature has moved to a new state: do that step's work.
| Pin | Type | Direction | Description |
|---|---|---|---|
CurrentState | FGameplayTag | in | The state it left (empty before the first). |
DesiredState | FGameplayTag | in | The state it is now in. |
K2_OnOtherFeatureChanged
Another feature on the actor has moved to a new state.
The component tries to move on itself afterwards.
| Pin | Type | Direction | Description |
|---|---|---|---|
Feature | FName | in | The other feature's name. |
State | FGameplayTag | in | The state it is now in. |
C++
Public C++ members that Blueprint does not see.
UGantryInitStateComponent
Starts the chain as the four InitState tags.
GetFeatureName
virtual FName
Returns: Feature Name, or the class name when it is empty.
CanChangeInitState
virtual bool
Asks Can Change Init State (Blueprint or C++).
HandleChangeInitState
virtual void
Runs On Init State Changed.
OnActorInitStateChanged
virtual void
Another feature on the actor moved: runs On Other Feature Changed, then tries to move on.
CheckDefaultInitialization
virtual void
Moves along Init States as far as Can Change Init State allows.