USMInstance¶
Module: SMSystem
#include <SMInstance.h>
Inherits from UObject, FTickableGameObject, ISMStateMachineInterface, ISMInstanceInterface
Inherited by USMEditorInstance
Description¶
The base class all blueprint state machines inherit from. Each instance contains a "Root" state machine which is the top-level FSM defined in the graph and accessible through GetRootStateMachineNodeInstance().
Instances need to be initialized before they can be used. The process is:
- Initialize(): Loads and maps out all contained states and transitions.
- LoadFromMultipleStates(): [Optional] Only needed if any saved states need to be loaded.
- Start(): Begins processing the state machine.
- Stop(): Stops updating and running the state machine.
- Shutdown(): Clears internal resources and empties the state machine. Initialize must be called again before use. This generally isn't necessary to call.
When using state machine components most methods should be called from the component instead.
See:
Public Functions¶
| Name | |
|---|---|
| USMInstance() | |
| void | Tick(float DeltaTime) override ![]() |
| virtual bool | IsTickable() const override ![]() |
| virtual bool | IsTickableInEditor() const override |
| virtual ETickableTickType | GetTickableTickType() const override |
| virtual bool | IsTickableWhenPaused() const override ![]() |
| virtual UWorld * | GetTickableGameObjectWorld() const override |
| virtual TStatId | GetStatId() const override |
| virtual bool | IsSupportedForNetworking() const override |
| virtual void | GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const override |
| virtual void | BeginDestroy() override |
| virtual UWorld * | GetWorld() const override |
| virtual int32 | GetFunctionCallspace(UFunction * Function, FFrame * Stack) override |
| virtual bool | CallRemoteFunction(UFunction * Function, void * Parms, FOutParmRec * OutParms, FFrame * Stack) override |
| virtual void | Serialize(FArchive & Ar) override |
| virtual UObject * | GetContext() const override ![]() |
| USMStateMachineComponent * | GetComponentOwner() const ![]() |
| void | SetComponentOwner(USMStateMachineComponent * InComponent) |
| virtual void | Initialize(UObject * Context) override ![]() |
| virtual void | Start() override ![]() |
| virtual void | Update(float DeltaSeconds =0.f) override ![]() |
| virtual void | Stop() override ![]() |
| virtual void | Restart() override ![]() |
| virtual void | Shutdown() override ![]() |
| void | ReplicatedStart() ![]() |
| void | ReplicatedStop() ![]() |
| void | ReplicatedRestart() ![]() |
| void | StartWithNewContext(UObject * Context) ![]() |
| void | EvaluateTransitions() ![]() |
| bool | EvaluateAndTakeTransitionChain(USMTransitionInstance * InFirstTransitionInstance) ![]() |
| bool | EvaluateAndTakeTransitionChain(FSMTransition & InFirstTransition) |
| bool | EvaluateAndFindTransitionChain(USMTransitionInstance * InFirstTransitionInstance, TArray< USMTransitionInstance * > & OutTransitionChain, USMStateInstance_Base *& OutDestinationState, bool bRequirePreviousStateActive =true) ![]() |
| bool | TakeTransitionChain(const TArray< USMTransitionInstance * > & InTransitionChain) ![]() |
| void | PreloadAllNodeInstances() ![]() |
| void | ActivateStateLocally(const FGuid & StateGuid, bool bActive, bool bSetAllParents, bool bActivateNow =true) |
| void | SwitchActiveState(USMStateInstance_Base * NewStateInstance, bool bDeactivateOtherStates =true) ![]() |
| void | SwitchActiveStateByQualifiedName(const FString & InFullPath, bool bDeactivateOtherStates =true) ![]() |
| bool | HasPendingActiveStates() const |
| bool | IsUpdating() const |
| bool | IsStopping() const ![]() |
| void | LoadFromState(const FGuid & FromGuid, bool bAllParents =true, bool bNotify =true) ![]() |
| void | LoadFromMultipleStates(const TArray< FGuid > & FromGuids, bool bNotify =true) ![]() |
| bool | AreInitialStatesSetFromLoad() const ![]() |
| void | ClearLoadedStates() ![]() |
| void | InitializeAsync(UObject * Context, const FOnStateMachineInstanceInitializedAsync & OnCompletedDelegate =FOnStateMachineInstanceInitializedAsync()) |
| void | K2_InitializeAsync(UObject * Context, FLatentActionInfo LatentInfo) ![]() |
| void | CancelAsyncInitialization() ![]() |
| void | WaitForAsyncInitializationTask(bool bCallFinishInitialize =true) ![]() |
| void | TryGetNestedActiveState(FSMStateInfo & FoundState, bool & bSuccess) const ![]() |
| FSMState_Base * | GetSingleActiveState() const |
| FSMState_Base * | GetSingleNestedActiveState() const |
| TArray< FSMState_Base * > | GetAllActiveStates() const |
| FGuid | GetSingleActiveStateGuid(bool bCheckNested =true) const ![]() |
| void | GetAllActiveStateGuids(TArray< FGuid > & ActiveGuids) const ![]() |
| TArray< FGuid > | GetAllActiveStateGuidsCopy() const |
| USMStateInstance_Base * | GetSingleActiveStateInstance(bool bCheckNested =true) const ![]() |
| void | GetAllActiveStateInstances(TArray< USMStateInstance_Base * > & ActiveStateInstances) const ![]() |
| TArray< USMInstance * > | GetAllReferencedInstances(bool bIncludeChildren =false) const ![]() |
| TArray< FSMStateMachine * > | GetStateMachinesWithReferences(bool bIncludeChildren =false) const |
| void | TryGetStateInfo(const FGuid & Guid, FSMStateInfo & StateInfo, bool & bSuccess) const ![]() |
| void | TryGetTransitionInfo(const FGuid & Guid, FSMTransitionInfo & TransitionInfo, bool & bSuccess) const ![]() |
| USMInstance * | GetReferencedInstanceByGuid(const FGuid & Guid) const ![]() |
| USMStateInstance_Base * | GetStateInstanceByGuid(const FGuid & Guid) const ![]() |
| USMTransitionInstance * | GetTransitionInstanceByGuid(const FGuid & Guid) const ![]() |
| USMNodeInstance * | GetNodeInstanceByGuid(const FGuid & Guid) const ![]() |
| USMStateInstance_Base * | GetStateInstanceByQualifiedName(const FString & InFullPath) const ![]() |
| FSMState_Base * | GetStateByGuid(const FGuid & Guid) const |
| FSMTransition * | GetTransitionByGuid(const FGuid & Guid) const |
| FSMNode_Base * | GetNodeByGuid(const FGuid & Guid) const |
| FSMState_Base * | FindStateByGuid(const FGuid & Guid) const |
| TMap< FGuid, FGuid > & | GetGuidRedirectMap() ![]() |
| void | SetGuidRedirectMap(const TMap< FGuid, FGuid > & InGuidMap) ![]() |
| FGuid | GetRedirectedGuid(const FGuid & InPathGuid) const |
| FSMStateMachine & | GetRootStateMachine() |
| USMStateMachineInstance * | GetRootStateMachineNodeInstance() const ![]() |
| bool | IsActive() const ![]() |
| bool | CanEverTick() const ![]() |
| void | SetCanEverTick(bool Value) ![]() |
| bool | IsTickRegistered() const |
| void | SetRegisterTick(bool Value) |
| void | SetTickOnManualUpdate(bool Value) ![]() |
| bool | CanTickOnManualUpdate() const ![]() |
| void | SetCanTickWhenPaused(bool Value) ![]() |
| void | SetCanTickInEditor(bool Value) |
| void | SetTickBeforeBeginPlay(bool Value) ![]() |
| void | SetTickInterval(float Value) ![]() |
| void | SetAutoManageTime(bool Value) ![]() |
| bool | CanAutoManageTime() const ![]() |
| float | GetTickInterval() const ![]() |
| void | SetStopOnEndState(bool Value) ![]() |
| bool | GetStopOnEndState() const ![]() |
| bool | IsInEndState() const ![]() |
| void | SetContext(UObject * Context) ![]() |
| const TMap< FGuid, FSMNode_Base * > & | GetNodeMap() const |
| const TMap< FGuid, FSMState_Base * > & | GetStateMap() const |
| const TMap< FGuid, FSMTransition * > & | GetTransitionMap() const |
| const TArray< FSMStateHistory > & | GetStateHistory() const ![]() |
| void | SetStateHistoryMaxCount(int32 NewSize) ![]() |
| int32 | GetStateHistoryMaxCount() const ![]() |
| void | ClearStateHistory() ![]() |
| void | GetAllStateInstances(TArray< USMStateInstance_Base * > & StateInstances) const ![]() |
| void | GetAllTransitionInstances(TArray< USMTransitionInstance * > & TransitionInstances) const ![]() |
| void | SetNetworkInterface(TScriptInterface< ISMStateMachineNetworkedInterface > InNetworkInterface) |
| TScriptInterface< ISMStateMachineNetworkedInterface > | GetNetworkInterface() const ![]() |
| void | K2_TryGetNetworkInterface(TScriptInterface< ISMStateMachineNetworkedInterface > & Interface, bool & bIsValid) ![]() |
| ISMStateMachineNetworkedInterface * | TryGetNetworkInterface() const |
| void | UpdateNetworkConditions() |
| void | CopyNetworkConditionsFrom(USMInstance * OtherInstance, bool bUpdateNodes =false) |
| void | SetAllowTransitionsLocally(bool bCanEvaluateTransitions, bool bCanTakeTransitions) |
| void | SetAllowStateLogic(bool bAllow) |
| bool | HasStarted() const ![]() |
| bool | IsInitialized() const ![]() |
| bool | IsInitializingAsync() const ![]() |
| bool | IsReferenceTemplate() const |
| void | SetReferenceOwner(USMInstance * Owner) |
| void | AddReplicatedReference(const FGuid & PathGuid, USMInstance * NewReference) |
| USMInstance * | FindReplicatedReference(const FGuid & PathGuid) const |
| const TArray< FSMReferenceContainer > & | GetReplicatedReferences() const |
| bool | HaveAllReferencesReplicated() const |
| bool | CanReplicateAsReference() const |
| const USMInstance * | GetReferenceOwnerConst() const |
| const USMInstance * | GetPrimaryReferenceOwnerConst() const |
| bool | IsPrimaryReferenceOwner() const |
| USMInstance * | GetReferenceOwner() const ![]() |
| USMInstance * | GetPrimaryReferenceOwner() ![]() |
| TSubclassOf< USMStateMachineInstance > | GetRootStateMachineNodeClass() const ![]() |
| TSubclassOf< USMStateMachineInstance > | GetStateMachineClass() const |
| void | SetRootStateMachineNodeClass(TSubclassOf< USMStateMachineInstance > NewStateMachineNodeClass) ![]() |
| void | SetStateMachineClass(TSubclassOf< USMStateMachineInstance > NewStateMachineClass) |
| void | OnPreStateMachineInitialized() ![]() |
| void | OnStateMachineInitialized() ![]() |
| void | OnStateMachineStart() ![]() |
| void | OnStateMachineUpdate(float DeltaSeconds) ![]() |
| void | OnStateMachineStop() ![]() |
| void | OnStateMachineShutdown() ![]() |
| void | OnStateMachineTransitionTaken(const FSMTransitionInfo & Transition) ![]() |
| void | OnStateMachineStateChanged(const FSMStateInfo & ToState, const FSMStateInfo & FromState) ![]() |
| void | OnStateMachineStateStarted(const FSMStateInfo & State) ![]() |
| void | NotifyTransitionTaken(const FSMTransition & Transition) |
| void | NotifyStateChange(FSMState_Base * ToState, FSMState_Base * FromState) |
| void | NotifyStateStarted(const FSMState_Base & State) |
| FSMDebugStateMachine & | GetDebugStateMachine() |
| const FSMDebugStateMachine & | GetDebugStateMachineConst() const |
| bool | IsLoggingEnabled() const |
| void | RunUpdateAsReference(float DeltaSeconds) |
| TEnumAsByte< ESMStateMachineInput::Type > | GetInputType() const Input. |
| int32 | GetInputPriority() const |
| bool | GetBlockInput() const |
| APlayerController * | GetInputController() const |
| void | SetAutoReceiveInput(ESMStateMachineInput::Type InInputType) |
| void | SetInputPriority(int32 InInputPriority) |
| void | SetBlockInput(bool bNewValue) |
| UInputComponent * | GetInputComponent() const ![]() |
| const TMap< FGuid, FSMGuidMap > & | GetRootPathGuidCache() const |
| void | SetRootPathGuidCache(const TMap< FGuid, FSMGuidMap > & InGuidCache) |
| TSharedPtr< FSMCachedPropertyData, ESPMode::ThreadSafe > | GetCachedPropertyData() |
| const TMap< FName, TObjectPtr< UObject > > & | GetGeneratedSubObjectTemplates() const |
| TMap< FGuid, FSMExposedNodeFunctions > & | GetNodeExposedFunctions() |
| void | AddNonThreadSafeNode(FSMNode_Base * InNode) |
| FString | GetRootNodeNameDefault() |
| FName | GetStateMachineClassPropertyName() |
| FName | GetInternalEventUpdateFunctionName() |
| FName | GetInternalEvaluateAndTakeTransitionChainFunctionName() |
| FName | GetInternalEventCleanupFunctionName() |
Protected Functions¶
Public Attributes¶
| Name | |
|---|---|
| FGuid | RootStateMachineGuid |
| FOnStateMachineInitializedSignature | OnPreStateMachineInitializedEvent |
| FOnStateMachineInitializedSignature | OnStateMachineInitializedEvent |
| FOnStateMachineStartedSignature | OnStateMachineStartedEvent |
| FOnStateMachineUpdatedSignature | OnStateMachineUpdatedEvent |
| FOnStateMachineStoppedSignature | OnStateMachineStoppedEvent |
| FOnStateMachineShutdownSignature | OnStateMachineShutdownEvent |
| FOnStateMachineTransitionTakenSignature | OnStateMachineTransitionTakenEvent |
| FOnStateMachineStateChangedSignature | OnStateMachineStateChangedEvent |
| FOnStateMachineStateStartedSignature | OnStateMachineStateStartedEvent |
| TArray< TObjectPtr< UObject > > | ReferenceTemplates |
Protected Attributes¶
Friends¶
| Name | |
|---|---|
| class | USMStateMachineComponent |
Public Functions Documentation¶
function USMInstance¶
function Tick¶

The native tick is required to update the state machine.
function IsTickable¶

function IsTickableInEditor¶
function GetTickableTickType¶
function IsTickableWhenPaused¶

function GetTickableGameObjectWorld¶
function GetStatId¶
function IsSupportedForNetworking¶
function GetLifetimeReplicatedProps¶
virtual void GetLifetimeReplicatedProps(
TArray< FLifetimeProperty > & OutLifetimeProps
) const override
function BeginDestroy¶
function GetWorld¶
function GetFunctionCallspace¶
function CallRemoteFunction¶
virtual bool CallRemoteFunction(
UFunction * Function,
void * Parms,
FOutParmRec * OutParms,
FFrame * Stack
) override
function Serialize¶
function GetContext¶

The object which this state machine is running for.
function GetComponentOwner¶

The component owning this instance. Will be null during initialization or if this state machine was created without a component.
function SetComponentOwner¶
Override the component owner. Should not be necessary to ever call unless you have a custom component which is managing initialization or replication.
function Initialize¶

Prepare the state machine for use.
Parameters:
Context- The context to use for the state machine.
function Start¶

Start the root state machine. This is a local call only and is not replicated.
function Update¶

Manual way of updating the root state machine if tick is disabled.
function Stop¶

Complete the state machine's current state and force the machine to end regardless of if the state is an end state. This is a local call only and is not replicated.
function Restart¶

Forcibly restart the state machine and place it back into an entry state. This is a local call only and is not replicated.
function Shutdown¶

Shutdown this instance. Calls Stop(). Must call Initialize() again before use. If the goal is to restart the state machine later call Stop() instead.
function ReplicatedStart¶

Calls Start() locally or on the component owner if valid.
function ReplicatedStop¶

Calls Stop() locally or on the component owner if valid.
function ReplicatedRestart¶

Calls Restart() locally or on the component owner if valid.
function StartWithNewContext¶

Sets a new context and starts the state machine. The state machine should be stopped prior to calling.
function EvaluateTransitions¶

Signals to the owning state machine to process transition evaluation. This is similar to calling Update on the owner root state machine, however state update logic (Tick) won't execute. All transitions are evaluated as normal starting from the root state machine down. Depending on super state transitions it's possible the state machine this state is part of may exit.
function EvaluateAndTakeTransitionChain¶

Evaluate an entire transition chain discovering the path to take. If an entire chain passes then switch to the destination state.
A transition chain is the first path that evaluates to true between two states, consisting of all transitions and conduits that are configured to eval with transitions.
This method fails if the state machine isn't state change authoritative. The destination state won't become active if this state machine doesn't have local state change authority.
If the method passes each transition taken will be replicated in order.
This method is for advanced usage and not required for normal operation.
Parameters:
InFirstTransitionInstance- The transition instance, which should be the first part of a transition chain.
Return: True if the chain succeeded evaluation.
function EvaluateAndTakeTransitionChain¶
function EvaluateAndFindTransitionChain¶
bool EvaluateAndFindTransitionChain(
USMTransitionInstance * InFirstTransitionInstance,
TArray< USMTransitionInstance * > & OutTransitionChain,
USMStateInstance_Base *& OutDestinationState,
bool bRequirePreviousStateActive =true
)

Evaluate an entire transition chain discovering the path to take. This will not switch states or take the transition chain. It will only discover the first valid transition chain at the moment of execution.
A transition chain is the first path that evaluates to true between two states, consisting of all transitions and conduits that are configured to eval with transitions. In many cases it is of size 0 or 1.
This should only be used for conditional (tick) evaluation. If an event has triggered a transition but the state machine has not taken it yet, this method may clear the event status preventing the transition from being taken natively.
If the transition chain returned should be taken, use TakeTransitionChain().
This method is for advanced usage and not required for normal operation.
Parameters:
InFirstTransitionInstance- The transition instance, which should be the first part of a transition chain.
OutTransitionChain- The first valid transition chain where every node has evaluated to true. Only transitions are returned.
OutDestinationState- The destination state at the end of the chain.
bRequirePreviousStateActive- If the previous state is not active then cancel evaluation.
Return: True if a valid transition chain was found.
function TakeTransitionChain¶

Tell the state machine to take a specific transition chain. The chain is assumed to be true and will not be evaluated. There is no integrity checking to make sure the chain properly connects two states. All other state change behavior is respected including requiring the previous state active.
This method is for advanced usage and not required for normal operation.
Parameters:
InTransitionChain- The transition chain to be taken consisting of transitions and conduits.
Return: True if the chain was taken and the state switched.
function PreloadAllNodeInstances¶

Ensure all default node instances are loaded into memory. Default node classes are normally loaded on demand to save on memory and initialization time. Preloading isn't necessary unless most default nodes need to be accessed programatically, such as calling GetNodeInstance() from a local state graph.
This has no effect on nodes assigned a custom node class.
function ActivateStateLocally¶
void ActivateStateLocally(
const FGuid & StateGuid,
bool bActive,
bool bSetAllParents,
bool bActivateNow =true
)
Activate or deactivate a single state locally. This call is not replicated. Use the SetActive method from the state instance to allow replication.
Parameters:
StateGuid- The guid of the specific state to activate.
bActive- Add or remove the state from the owning state machine's active states.
bSetAllParents- Sets the active state of all super state machines. A parent state machine won't be deactivated unless there are no other states active.
bActivateNow- If the state is becoming active it will run OnStateBegin this tick. If this is false it will run on the next update cycle.
function SwitchActiveState¶
void SwitchActiveState(
USMStateInstance_Base * NewStateInstance,
bool bDeactivateOtherStates =true
)

Switch the activate state. Does not take any transition. Handles replication and requires state change authority.
Parameters:
NewStateInstance- The state to switch to. Null is accepted if you wish to deactivate all other states.
bDeactivateOtherStates- If other states should be deactivated first. A state won't be deactivated if it is a super state machine to the new state.
function SwitchActiveStateByQualifiedName¶
void SwitchActiveStateByQualifiedName(
const FString & InFullPath,
bool bDeactivateOtherStates =true
)

Switch to a state instance by its fully qualified name in a state machine blueprint. Does not take any transition. Handles replication and requires state change authority.
A top level state name of "Locomotion" would be found by searching "Locomotion". A nested state of name "Jump" within a "Locomotion" state machine would be found by "Locomotion.Jump".
It is not necessary to include the "Root" state machine node in the search.
The search is performed iteratively and the performance is roughly O(n) by number of nodes in the path. The lookup of each state is O(1).
Parameters:
InFullPath- The full path to the node. When the state machine type is known a UI dropdown is available. Cast the target and refresh the node to update the UI.
bDeactivateOtherStates- If other states should be deactivated first. A state won't be deactivated if it is a super state machine to the new state.
function HasPendingActiveStates¶
If there are states that need their active state changed.
function IsUpdating¶
If this state machine instance is in an update cycle.
function IsStopping¶

If the state machine instance is currently in the process of stopping. This will also be true if the state machine was stopped via bStopOnEndState.
function LoadFromState¶

Sets a temporary initial state of the guid's owning state machine. When the state machine starts it will default to this state. With AllParents to true this is useful for restoring a single active state of a state machine from GetSingleActiveStateGuid(). If there are multiple active states, or the state of non active sub state machines is important use LoadFromMultipleStates() instead.
This should only be called on an initialized state machine that is stopped.
When using with replication this should be called from the server, or from a client that has state change authority.
Parameters:
FromGuid- The state guid to load.
bAllParents- Recursively set the initial state of all parent state machines.
bNotify- Calls OnStateMachineInitialStateLoaded on this instance and sets AreInitialStatesSetFromLoad().
function LoadFromMultipleStates¶

Set all owning parents' temporary initial state to the given guids. Useful for restoring multiple states within a state machine. Best used when restoring from GetAllActiveStateGuids(). When the state machine starts it will default to these states.
This should only be called on an initialized state machine that is stopped.
When using with replication this should be called from the server, or from a client that has state change authority.
Parameters:
FromGuids- Array of state guids to load.
bNotify- Calls OnStateMachineInitialStateLoaded on this instance and sets AreInitialStatesSetFromLoad().
function AreInitialStatesSetFromLoad¶

Checks if initial entry states have been set through LoadFromState() or LoadFromMultipleStates(). This will be true if at least one state was loaded this way and will become false once Stop() is called.
In a replicated environment this is only accurate when called from the machine that performed the initial load.
function ClearLoadedStates¶

Clear all temporary initial states loaded through LoadFromState(). Do not use while the state machine is active and replicated.
function InitializeAsync¶
void InitializeAsync(
UObject * Context,
const FOnStateMachineInstanceInitializedAsync & OnCompletedDelegate =FOnStateMachineInstanceInitializedAsync()
)
Prepare the state machine for use on a separate thread. If this object needs to be destroyed before the process completes you should call Shutdown() or CancelAsyncInitialization() to attempt to safely exit the thread.
Parameters:
Context- The context to use for the state machine.
OnCompletedDelegate- A callback delegate for when initialization completes. This only will fire if initialization was a success.
function K2_InitializeAsync¶

Prepare the state machine for use on a separate thread. If this object needs to be destroyed before the process completes you should call Shutdown() or CancelAsyncInitialization() to attempt to safely exit the thread.
Parameters:
Context- The context to use for the state machine. This object must have a valid world assigned for a latent task to process correctly.
function CancelAsyncInitialization¶

Attempt to cancel the async initialization task.
function WaitForAsyncInitializationTask¶

Wait blocking for the async task to complete. The object may not be fully initialized after this as FinishInitialize must occur on the game thread and is scheduled to run through Unreal's task graph system.
Code that should execute after initialization is completed ideally should be done through the call back of InitializeAsync(). However, if bCallFinishInitialize is set, it should be safe to execute code on this instance after this call. Check IsInitialized() to validate the instance has successfully initialized.
Parameters:
bCallFinishInitialize- Call FinishInitialize immediately after the task completes if required on this thread. (Only valid if on GameThread)
function TryGetNestedActiveState¶

Retrieve the lowest level single active state including all nested state machines. Returns read only information.
function GetSingleActiveState¶
Return the current top level active state. Do not use if there are multiple active states.
Return: null or the first active top level state.
function GetSingleNestedActiveState¶
Retrieve the first lowest level active state including all nested state machines. Do not use if there are multiple active states.
Return: null or the first active state.
function GetAllActiveStates¶
Recursively retrieve all active states.
function GetSingleActiveStateGuid¶

Retrieve the first active state Guid. If a state is not active an invalid Guid will be returned. For multiple states GetAllActiveStateGuids() should be called instead.
Parameters:
bCheckNested- Check nested state machines.
Return: the first active state guid.
function GetAllActiveStateGuids¶

Recursively retrieve the guids of all active states. Useful if saving the current state of a state machine.
Parameters:
ActiveGuids- [Out] All current ActiveGuids. May be empty. Resets on method start.
function GetAllActiveStateGuidsCopy¶
Convenience method wrapper for GetAllActiveStateGuids().
Recursively retrieve the guids of all active states. Useful if saving the current state of a state machine.
Return: All current ActiveGuids. May be empty.
function GetSingleActiveStateInstance¶

Locate the first active state instance. For multiple states GetAllActiveStateInstances() should be called instead.
Parameters:
bCheckNested- Check nested state machines.
Return: A single active state's node instance.
function GetAllActiveStateInstances¶

Recursively retrieve all active state instances.
Parameters:
ActiveStateInstances- [Out] All active state instances. May be empty. Resets on method start.
function GetAllReferencedInstances¶

Find all referenced instances. IncludeChildren will return all nested state machine references.
function GetStateMachinesWithReferences¶
Find all internal state machine structs which contain references.
function TryGetStateInfo¶

Quickly returns read only information of the state belonging to the given guid. This always executes from the primary instance.
function TryGetTransitionInfo¶
void TryGetTransitionInfo(
const FGuid & Guid,
FSMTransitionInfo & TransitionInfo,
bool & bSuccess
) const

Quickly returns read only information of the transition belonging to the given guid. This always executes from the primary instance.
function GetReferencedInstanceByGuid¶

Quickly return a referenced instance given a state machine guid. This always executes from the primary instance.
function GetStateInstanceByGuid¶

Quickly return a state instance given the state guid. This always executes from the primary instance.
function GetTransitionInstanceByGuid¶

Quickly return a transition instance given a transition guid. This always executes from the primary instance.
function GetNodeInstanceByGuid¶

Quickly return any type of node instance. These could be transitions or states. This always executes from the primary instance.
function GetStateInstanceByQualifiedName¶

Return a state instance by its fully qualified name in a state machine blueprint. A top level state name of "Locomotion" would be found by searching "Locomotion". A nested state of name "Jump" within a "Locomotion" state machine would be found by "Locomotion.Jump".
It is not necessary to include the "Root" state machine node in the search.
The search is performed iteratively and the performance is roughly O(n) by number of nodes in the path. The lookup of each state is O(1).
Parameters:
InFullPath- The full path to the node. When the state machine type is known a UI dropdown is available. Cast the target and refresh the node to update the UI.
function GetStateByGuid¶
Quick lookup of a state by guid. Includes all nested.
function GetTransitionByGuid¶
Quick lookup of any transition by guid. Includes all nested.
function GetNodeByGuid¶
Quick lookup of any node by guid. Includes all nested.
function FindStateByGuid¶
Linear search all state machines for a contained node.
function GetGuidRedirectMap¶

A map of path guids which should be redirected to other path guids.
function SetGuidRedirectMap¶

Directly set the guid redirect map.
function GetRedirectedGuid¶
Find a redirected path guid.
Parameters:
InPathGuid- The old path guid which should point to a new guid.
Return: The redirected guid, or the original guid.
function GetRootStateMachine¶
The root state machine which may contain nested state machines.
function GetRootStateMachineNodeInstance¶

Return the root USMStateMachineInstance node.
This is relative to the SMInstance you are calling it from. If this is a state machine reference it will return the reference's root state machine node instance.
To retrieve the primary root state machine node instance, call this method from GetPrimaryReferenceOwner().
function IsActive¶

function CanEverTick¶

function SetCanEverTick¶

Set the conditional tick state. If false IsTickable() will return false. This will also update the component owner network settings if this call is made from the primary instance.
function IsTickRegistered¶
If the tick function has been registered.
function SetRegisterTick¶
When false prevents the tick function from ever being registered. Can only be called along with initialize and cannot be changed.
function SetTickOnManualUpdate¶

function CanTickOnManualUpdate¶

function SetCanTickWhenPaused¶

function SetCanTickInEditor¶
function SetTickBeforeBeginPlay¶

function SetTickInterval¶

Time in seconds between native ticks. This mostly affects the "Update" rate of the state machine. Overloaded Ticks won't be affected.
function SetAutoManageTime¶

function CanAutoManageTime¶

function GetTickInterval¶

function SetStopOnEndState¶

function GetStopOnEndState¶

function IsInEndState¶

True if the root state machine is in an end state.
function SetContext¶

Sets a new context.
function GetNodeMap¶
Get all mapped PathGuids to nodes.
function GetStateMap¶
Get all mapped PathGuids to states.
function GetTransitionMap¶
Get all mapped PathGuids to transitions.
function GetStateHistory¶

Retrieve an ordered history of states, oldest to newest, not including active state(s). This always executes from the primary instance.
function SetStateHistoryMaxCount¶

Sets the maximum number of states to record into history. Resizes the array removing older entries if needed.
Parameters:
NewSize- The number of states to record. Set to -1 for no limit.
function GetStateHistoryMaxCount¶

Return the maximum history count.
function ClearStateHistory¶

Empty the state history array.
function GetAllStateInstances¶

Retrieve all state instances throughout the entire state machine blueprint. These can be states, state machines, and conduits.
This includes all nested states in sub state machines and references. This does not include State Stack instances.
To retrieve only top level states call GetRootStateMachineNodeInstance() and from there call 'GetAllStateInstances'.
function GetAllTransitionInstances¶

Retrieve all transition instances throughout the entire state machine blueprint.
This includes all transitions nested in sub state machines and references. This does not include Transition Stack instances.
function SetNetworkInterface¶
void SetNetworkInterface(
TScriptInterface< ISMStateMachineNetworkedInterface > InNetworkInterface
)
Notifies this instance there is a server interface.
function GetNetworkInterface¶

Return the server interface if there is one. This may be null. Always executes from the primary instance.
function K2_TryGetNetworkInterface¶
void K2_TryGetNetworkInterface(
TScriptInterface< ISMStateMachineNetworkedInterface > & Interface,
bool & bIsValid
)

Return the server interface if there is one. This may be null. Always executes from the primary instance.
function TryGetNetworkInterface¶
Return the network interface if it set and if networking is enabled. Always executes from the primary instance.
function UpdateNetworkConditions¶
Updates all needed nodes with the current network conditions. Best to be called after Initialization and before Start.
function CopyNetworkConditionsFrom¶
Copy network settings from the other instance.
function SetAllowTransitionsLocally¶
Notifies state machines they are allowed to take transitions locally.
Parameters:
bCanEvaluateTransitions- If a state machine can check transition results.
bCanTakeTransitions- If a state machine can take a transition after evaluating it.
function SetAllowStateLogic¶
Notifies state machines if they are allowed to execute state logic locally.
function HasStarted¶

True if the instance has started.
function IsInitialized¶

If this instance is fully initialized.
function IsInitializingAsync¶

True only during async initialization.
function IsReferenceTemplate¶
If this is an archetype object used as custom defaults for a reference.
function SetReferenceOwner¶
Notify this instance is a reference owned by another instance.
function AddReplicatedReference¶
Record a reference to be replicated to the client.
function FindReplicatedReference¶
Find a replicated reference by its path guid.
function GetReplicatedReferences¶
Return all references set to be replicated.
function HaveAllReferencesReplicated¶
Checks if all references on the primary instance have been received.
function CanReplicateAsReference¶
If this instance is allowed to replicate if it is a reference.
function GetReferenceOwnerConst¶
Get the instance owning this reference. If null this is not a reference.
function GetPrimaryReferenceOwnerConst¶
Look up the owners to find the top-most instance.
function IsPrimaryReferenceOwner¶
Check if this is the top most instance.
function GetReferenceOwner¶

Get the instance owning this reference. If null this is not a reference.
function GetPrimaryReferenceOwner¶

Look up the owners to find the top-most instance. Could be this instance.
function GetRootStateMachineNodeClass¶

The custom state machine node class assigned to the root state machine node.
function GetStateMachineClass¶
Deprecated:
Use GetRootStateMachineNodeClass() instead.
function SetRootStateMachineNodeClass¶
inline void SetRootStateMachineNodeClass(
TSubclassOf< USMStateMachineInstance > NewStateMachineNodeClass
)

Sets the root state machine node class.
Parameters:
NewStateMachineNodeClass- The state machine node class to set.
function SetStateMachineClass¶
Deprecated:
Use SetRootStateMachineNodeClass() instead.
function OnPreStateMachineInitialized¶

Called at the beginning of Initialize(). Most information will not be available at this stage other than the context.
Warning:
When using async initialization this does not run on the game thread. Make sure your code is thread safe!
function OnStateMachineInitialized¶

Called when the instance is first initialized.
function OnStateMachineStart¶

Called right before the root state machine starts its initial state.
function OnStateMachineUpdate¶

Called right before the root state machine updates.
function OnStateMachineStop¶

Called right after the instance has been stopped.
function OnStateMachineShutdown¶

Called right after the instance has been shutdown. This will not fire if this object is being destroyed.
function OnStateMachineTransitionTaken¶

Called when a transition has evaluated to true and is being taken.
function OnStateMachineStateChanged¶

Called when a state machine has switched states.
function OnStateMachineStateStarted¶

Called when a state has started. This happens after OnStateMachineStateChanged and all previous transitions have evaluated.
function NotifyTransitionTaken¶
Send transition events.
function NotifyStateChange¶
Send state change events.
function NotifyStateStarted¶
Send state started events.
function GetDebugStateMachine¶
function GetDebugStateMachineConst¶
function IsLoggingEnabled¶
function RunUpdateAsReference¶
Call from an FSM reference. Avoids the update cancelling out if already in progress and keeps behavior consistent with normal nested FSMs.
function GetInputType¶
Input.
Get the AutoReceiveInput type.
function GetInputPriority¶
Get the input priority.
function GetBlockInput¶
Get the block input value.
function GetInputController¶
Attempt to find a valid player controller for this state machine. Requires input enabled and may return null.
function SetAutoReceiveInput¶
Sets the auto receive input functionality. Should be done prior to initialization.
function SetInputPriority¶
Sets the input priority. Should be done prior to initialization.
function SetBlockInput¶
Sets the input priority. Should be done prior to initialization.
function GetInputComponent¶

Retrieve the input component this state machine created with AutoReceiveInput. The input component will only be valid if AutoReceiveInput is not disabled and this state machine is initialized.
Return: The UInputComponent or nullptr.
function GetRootPathGuidCache¶
Retrieve the guid cache of all root FSMs and their contained nodes.
function SetRootPathGuidCache¶
Update the guid cache.
function GetCachedPropertyData¶
Retrieve the cached property data which is only needed during initialization. If called after initialization the cache may be recalculated.
function GetGeneratedSubObjectTemplates¶
Retrieve archetype objects used for instantiating node instances and references.
function GetNodeExposedFunctions¶
NodeGuid -> ExposedNodeFunctions. This is mapped by NODE guid - not path guid - and should always be called from nodes directly owned by this instance. IE nodes contained in a reference sm won't be found unless called on the reference.
Pointers to the contained exposed function array are set on each node instance using it. This is done to offset struct blueprint storage costs during compile, allowing larger state machines.
This map is set by the compiler and should not be modified post initialize as there will be the potential for memory stomps on initialized nodes.
function AddNonThreadSafeNode¶
Signal a node isn't thread safe to prevent it from loading async.
function GetRootNodeNameDefault¶
The default root node name to assign. Should never be changed.
function GetStateMachineClassPropertyName¶
The name of the StateMachineClass property, which represents the RootStateMachineNodeClass.
function GetInternalEventUpdateFunctionName¶
function GetInternalEvaluateAndTakeTransitionChainFunctionName¶
function GetInternalEventCleanupFunctionName¶
Protected Functions Documentation¶
function OnStateMachineInitialStateLoaded¶

Called after an initial state has been set with LoadFromState() or LoadFromMultipleStates(). This may be called multiple times depending whether there is more than one state being loaded or if parent state machines are also being loaded.
Parameters:
StateGuid- The guid of the state being loaded. The state instance can be retrieved with GetStateInstanceByGuid.
function OnStateMachineInitialStateLoaded_Implementation¶
function FinishInitialize¶
Called after Initialize sequence completed for methods that must run on the GameThread.
function HandleStopOnEndState¶
Check if in an end state and stop.
Return: true if stopped.
function CleanupAsyncObjects¶
Async objects need their async flags removed so they can be garbage collected.
function CleanupAsyncInitializationTask¶
Wait for the async task to complete and free memory on completion.
function Tick_Implementation¶
function OnPreStateMachineInitialized_Implementation¶
function OnStateMachineInitialized_Implementation¶
function OnStateMachineStart_Implementation¶
function OnStateMachineUpdate_Implementation¶
function OnStateMachineStop_Implementation¶
function OnStateMachineShutdown_Implementation¶
function OnStateMachineTransitionTaken_Implementation¶
inline virtual void OnStateMachineTransitionTaken_Implementation(
const FSMTransitionInfo & Transition
)
function OnStateMachineStateChanged_Implementation¶
inline virtual void OnStateMachineStateChanged_Implementation(
const FSMStateInfo & ToState,
const FSMStateInfo & FromState
)
function OnStateMachineStateStarted_Implementation¶
function Internal_Update¶
Internal update logic. Can be called during an update and used by event triggers.
function Internal_EvaluateAndTakeTransitionChainByGuid¶
Internal logic for taking a transition chain by the path guid.
function Internal_EventUpdate¶
Internal logic from when an auto-bound event might trigger an update.
function Internal_EventCleanup¶
Internal cleanup logic after an auto-bound event fires.
function BuildStateMachineMap¶
Assemble a complete map of all nested nodes and state machines. Builds out GuidNodeMap and StateMachineGuids. InstancesMapped keeps track of all instances built to prevent stack overflow in the event of state machine references that self reference.
function BuildStateMachineMap¶
void BuildStateMachineMap(
FSMStateMachine * StateMachine,
TSet< USMInstance * > & InstancesMapped
)
function CheckIsInitialized¶
Logs a warning if not initialized.
function UpdateTime¶
Records time running so delta time can be established if not ticking or providing accurate delta seconds.
function RecordPreviousStateHistory¶
Record the given state into the state history.
function TrimStateHistory¶
Makes sure state history current count doesn't exceed max count.
Public Attributes Documentation¶
variable RootStateMachineGuid¶
Used to identify the root state machine during initialization. This is not a calculated value and represents the NodeGuid.
variable OnPreStateMachineInitializedEvent¶
Called at the beginning of Initialize(). Most information will not be available at this stage other than the context.
Warning:
This will not fire when the state machine is initialized async, as the broadcast is not thread safe.
variable OnStateMachineInitializedEvent¶
Called when the state machine is first initialized.
variable OnStateMachineStartedEvent¶
Called right before the state machine is started.
variable OnStateMachineUpdatedEvent¶
Called right before the state machine is updated.
variable OnStateMachineStoppedEvent¶
Called right after the state machine has ended.
variable OnStateMachineShutdownEvent¶
Called right after the state machine has shutdown.
variable OnStateMachineTransitionTakenEvent¶
Called when a transition has evaluated to true and is being taken.
variable OnStateMachineStateChangedEvent¶
Called when a state machine has switched states.
variable OnStateMachineStateStartedEvent¶
Called when a state has started. This happens after OnStateMachineStateChanged and all previous transitions have evaluated.
variable ReferenceTemplates¶
Deprecated:
Object templates are now stored on the Blueprint Generated Class. Access by calling GetGeneratedSubObjectTemplates() instead.
Protected Attributes Documentation¶
variable ComponentOwner¶
The component owning this instance.
variable NetworkInterface¶
Pointer to server object to notify of active transitions.
variable GuidNodeMap¶
Flattened map of all node Path Guids -> Node references
variable GuidStateMap¶
Flattened map of all state Path Guids -> State references.
variable GuidTransitionMap¶
Flattened map of all transition Path Guids -> Transition references.
variable StateMachineGuids¶
Map of all StateMachine Path Guids
variable RootStateMachine¶
Top level state machine
variable R_StateMachineContext¶
The context to run the state machine in.
variable ReferenceOwner¶
If this instance is owned by another instance making this a reference.
variable StateMachineClass¶
The custom state machine node class assigned to the root state machine. This is used for rule evaluation, for exposing variables on state machine references, or for compile validation.
variable bAutoManageTime¶
Automatically calculate delta seconds if none are provided. Requires context with a valid World.
variable bStopOnEndState¶
Should this instance stop itself once an end state has been reached. An Update call is required for this to occur.
variable bCanEverTick¶
Should this instance tick. By default it will update the state machine.
variable bCanTickInEditor¶
Should this instance tick in editor.
variable bCanTickWhenPaused¶
Should this instance tick when the game is paused.
variable bTickRegistered¶
Setting to false physically prevents the tick function from being registered and the instance from ever ticking. This is different from bCanEverTick in that it cannot be changed and it also offers slightly better performance.
This is generally best used with non-component state machines created by CreateStateMachineInstance.
variable bTickBeforeInitialize¶
Allow the state machine to tick before it is initialized. This likely isn't necessary as CreateStateMachineInstance will initialize the state machine.
variable bTickBeforeBeginPlay¶
When false IsTickable checks if the world has started play.
variable TickInterval¶
Time in seconds between native ticks. This mostly affects the "Update" rate of the state machine. Overloaded Ticks won't be affected.
variable TimeSinceAllowedTick¶
Time since the last valid tick occurred.
variable WorldSeconds¶
variable WorldTimeDelta¶
variable InputComponent¶
variable AutoReceiveInput¶
Automatically registers this state machine to receive input from a player. Input events placed in the event graph will always fire and execute.
Input placed in node graphs will ALWAYS fire (consume input if checked) but only execute their logic while the node is initialized.
Example: State A is entered. Any input events in state A and all outbound transitions including conduits will fire and execute when the key is pressed. Once State A exits all of the input events will still fire when pressed, but any blueprint logic will not execute.
If consuming input is a problem, either uncheck the ConsumeInput option on the input event, or create a custom node class and use input actions there.
variable InputPriority¶
The priority of this input component when pushed in to the stack.
variable bBlockInput¶
Whether any components lower on the input stack should be allowed to receive input.
variable StateHistory¶
End Input.
Ordered history of states, oldest to newest, not including active state(s).
variable StateHistoryMaxCount¶
The total number of states to keep in history. Set to -1 for no limit.
variable bEnableLogging¶
Enable info logging for the state machine.
variable bLogStateChange¶
Log when a state change occurs. This includes when a state machine starts or exits where transitions won't apply.
variable bLogTransitionTaken¶
Log whenever a transition occurs.
variable bCanReplicateAsReference¶
If this specific instance should be replicated if it is referenced by another state machine. Requires a component and proper network setup. This allows RPCs and replicated variables defined on this blueprint to work and is not required just for the state machine to function on the network.
The primary instance will always be replicated when the component replicates.
variable bCallTickOnManualUpdate¶
The Update method will call Tick only if Update was not called by native Tick.
variable bIsTicking¶
True if currently ticking.
variable bIsUpdating¶
True if currently updating.
variable bCanEvaluateTransitionsLocally¶
Should this instance be allowed to process transitions.
variable bCanTakeTransitionsLocally¶
Should this instance take transitions or only notify the server.
variable bCanExecuteStateLogic¶
Should this instance be allowed to execute state logic.
variable bHasStarted¶
True once the instance has started.
variable bLoadFromStatesCalled¶
This will be true if at least one initial state was set from user load and will always be set to false on Stop().
variable bInitialized¶
Signal the state machine has been initialized. Normally set automatically when calling Initialize().
variable bWaitingForStop¶
If the state machine is waiting for a stop command. Only used for networking. Needs to be under instance for more precise control, similar to how individual transitions know when they need to wait.
variable bIsStopping¶
If the state machine instance is currently stopping.
Private Attributes Documentation¶
variable StatesPendingActivation¶
States that need to be activated or deactivated, stored to help the update cycle in the event an end state is detected prematurely.
variable OnPreGarbageCollectHandle¶
variable AsyncInitializationTask¶
The async initialization task.
variable OnStateMachineInitializedAsyncDelegate¶
Set from caller of initialize async function.
variable OnReferencesReplicatedEvent¶
variable ReplicatedReferences¶
Set at initialization time on the primary instance, containing all nested references. Used for reference replicated variables.
variable bInitializingAsync¶
True only during async initialization.
variable PathGuidRedirectMap¶
A map of PathGuids which should be redirected to other PathGuids. A PathGuid is the guid generated at run-time during initialization which is unique per node based on the node's path in the state machine. The generated PathGuid is deterministic and has support for references and parent graphs.
Guid redirects aren't necessary unless you modify a node's path in the state machine and have to support loading data from a previous version which may have used the old guids.
variable RootPathGuidCache¶
A flattened map of Root FSM (this instance plus references) path guids each containing all of their immediate node to path guids.
variable CachedPropertyData¶
Cached property data for this state machine instance. Once mapped it includes properties of this instance and all contained node classes.