Skip to content

USMInstance

Module: SMSystem

#include <SMInstance.h>

Inherits from UObject, FTickableGameObject, ISMStateMachineInterface, ISMInstanceInterface

Inherited by USMEditorInstance

Description

class USMInstance;

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
images/classes/SMInstance/img/nd_img_Tick.png
virtual bool IsTickable() const override
images/classes/SMInstance/img/nd_img_IsTickable.png
virtual bool IsTickableInEditor() const override
virtual ETickableTickType GetTickableTickType() const override
virtual bool IsTickableWhenPaused() const override
images/classes/SMInstance/img/nd_img_IsTickableWhenPaused.png
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 UObject * GetContext() const override
images/classes/SMInstance/img/nd_img_GetContext.png
USMStateMachineComponent * GetComponentOwner() const
images/classes/SMInstance/img/nd_img_GetComponentOwner.png
void SetComponentOwner(USMStateMachineComponent * InComponent)
virtual void Initialize(UObject * Context) override
images/classes/SMInstance/img/nd_img_Initialize.png
virtual void Start() override
images/classes/SMInstance/img/nd_img_Start.png
virtual void Update(float DeltaSeconds =0.f) override
images/classes/SMInstance/img/nd_img_Update.png
virtual void Stop() override
images/classes/SMInstance/img/nd_img_Stop.png
virtual void Restart() override
images/classes/SMInstance/img/nd_img_Restart.png
virtual void Shutdown() override
images/classes/SMInstance/img/nd_img_Shutdown.png
void ReplicatedStart()
images/classes/SMInstance/img/nd_img_ReplicatedStart.png
void ReplicatedStop()
images/classes/SMInstance/img/nd_img_ReplicatedStop.png
void ReplicatedRestart()
images/classes/SMInstance/img/nd_img_ReplicatedRestart.png
void StartWithNewContext(UObject * Context)
images/classes/SMInstance/img/nd_img_StartWithNewContext.png
void EvaluateTransitions()
images/classes/SMInstance/img/nd_img_EvaluateTransitions.png
bool EvaluateAndTakeTransitionChain(USMTransitionInstance * InFirstTransitionInstance)
images/classes/SMInstance/img/nd_img_EvaluateAndTakeTransitionChain.png
bool EvaluateAndTakeTransitionChain(FSMTransition & InFirstTransition)
bool EvaluateAndFindTransitionChain(USMTransitionInstance * InFirstTransitionInstance, TArray< USMTransitionInstance * > & OutTransitionChain, USMStateInstance_Base *& OutDestinationState, bool bRequirePreviousStateActive =true)
images/classes/SMInstance/img/nd_img_EvaluateAndFindTransitionChain.png
bool TakeTransitionChain(const TArray< USMTransitionInstance * > & InTransitionChain)
images/classes/SMInstance/img/nd_img_TakeTransitionChain.png
void PreloadAllNodeInstances()
images/classes/SMInstance/img/nd_img_PreloadAllNodeInstances.png
void ActivateStateLocally(const FGuid & StateGuid, bool bActive, bool bSetAllParents, bool bActivateNow =true)
void SwitchActiveState(USMStateInstance_Base * NewStateInstance, bool bDeactivateOtherStates =true)
images/classes/SMInstance/img/nd_img_SwitchActiveState.png
void SwitchActiveStateByQualifiedName(const FString & InFullPath, bool bDeactivateOtherStates =true)
images/classes/SMInstance/img/nd_img_SwitchActiveStateByQualifiedName.png
bool HasPendingActiveStates() const
bool IsUpdating() const
bool IsStopping() const
images/classes/SMInstance/img/nd_img_IsStopping.png
void LoadFromState(const FGuid & FromGuid, bool bAllParents =true, bool bNotify =true)
images/classes/SMInstance/img/nd_img_LoadFromState.png
void LoadFromMultipleStates(const TArray< FGuid > & FromGuids, bool bNotify =true)
images/classes/SMInstance/img/nd_img_LoadFromMultipleStates.png
bool AreInitialStatesSetFromLoad() const
images/classes/SMInstance/img/nd_img_AreInitialStatesSetFromLoad.png
void ClearLoadedStates()
images/classes/SMInstance/img/nd_img_ClearLoadedStates.png
void InitializeAsync(UObject * Context, const FOnStateMachineInstanceInitializedAsync & OnCompletedDelegate =FOnStateMachineInstanceInitializedAsync())
void K2_InitializeAsync(UObject * Context, FLatentActionInfo LatentInfo)
images/classes/SMInstance/img/nd_img_K2_InitializeAsync.png
void CancelAsyncInitialization()
void WaitForAsyncInitializationTask(bool bCallFinishInitialize =true)
void TryGetNestedActiveState(FSMStateInfo & FoundState, bool & bSuccess) const
images/classes/SMInstance/img/nd_img_TryGetNestedActiveState.png
FSMState_Base * GetSingleActiveState() const
FSMState_Base * GetSingleNestedActiveState() const
TArray< FSMState_Base * > GetAllActiveStates() const
FGuid GetSingleActiveStateGuid(bool bCheckNested =true) const
images/classes/SMInstance/img/nd_img_GetSingleActiveStateGuid.png
void GetAllActiveStateGuids(TArray< FGuid > & ActiveGuids) const
images/classes/SMInstance/img/nd_img_GetAllActiveStateGuids.png
TArray< FGuid > GetAllActiveStateGuidsCopy() const
USMStateInstance_Base * GetSingleActiveStateInstance(bool bCheckNested =true) const
images/classes/SMInstance/img/nd_img_GetSingleActiveStateInstance.png
void GetAllActiveStateInstances(TArray< USMStateInstance_Base * > & ActiveStateInstances) const
images/classes/SMInstance/img/nd_img_GetAllActiveStateInstances.png
TArray< USMInstance * > GetAllReferencedInstances(bool bIncludeChildren =false) const
images/classes/SMInstance/img/nd_img_GetAllReferencedInstances.png
TArray< FSMStateMachine * > GetStateMachinesWithReferences(bool bIncludeChildren =false) const
void TryGetStateInfo(const FGuid & Guid, FSMStateInfo & StateInfo, bool & bSuccess) const
images/classes/SMInstance/img/nd_img_TryGetStateInfo.png
void TryGetTransitionInfo(const FGuid & Guid, FSMTransitionInfo & TransitionInfo, bool & bSuccess) const
images/classes/SMInstance/img/nd_img_TryGetTransitionInfo.png
USMInstance * GetReferencedInstanceByGuid(const FGuid & Guid) const
images/classes/SMInstance/img/nd_img_GetReferencedInstanceByGuid.png
USMStateInstance_Base * GetStateInstanceByGuid(const FGuid & Guid) const
images/classes/SMInstance/img/nd_img_GetStateInstanceByGuid.png
USMTransitionInstance * GetTransitionInstanceByGuid(const FGuid & Guid) const
images/classes/SMInstance/img/nd_img_GetTransitionInstanceByGuid.png
USMNodeInstance * GetNodeInstanceByGuid(const FGuid & Guid) const
images/classes/SMInstance/img/nd_img_GetNodeInstanceByGuid.png
USMStateInstance_Base * GetStateInstanceByQualifiedName(const FString & InFullPath) const
images/classes/SMInstance/img/nd_img_GetStateInstanceByQualifiedName.png
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()
images/classes/SMInstance/img/nd_img_GetGuidRedirectMap.png
void SetGuidRedirectMap(const TMap< FGuid, FGuid > & InGuidMap)
images/classes/SMInstance/img/nd_img_SetGuidRedirectMap.png
FGuid GetRedirectedGuid(const FGuid & InPathGuid) const
FSMStateMachine & GetRootStateMachine()
USMStateMachineInstance * GetRootStateMachineNodeInstance() const
images/classes/SMInstance/img/nd_img_GetRootStateMachineNodeInstance.png
bool IsActive() const
images/classes/SMInstance/img/nd_img_IsActive.png
bool CanEverTick() const
images/classes/SMInstance/img/nd_img_CanEverTick.png
void SetCanEverTick(bool Value)
images/classes/SMInstance/img/nd_img_SetCanEverTick.png
bool IsTickRegistered() const
void SetRegisterTick(bool Value)
void SetTickOnManualUpdate(bool Value)
images/classes/SMInstance/img/nd_img_SetTickOnManualUpdate.png
bool CanTickOnManualUpdate() const
images/classes/SMInstance/img/nd_img_CanTickOnManualUpdate.png
void SetCanTickWhenPaused(bool Value)
images/classes/SMInstance/img/nd_img_SetCanTickWhenPaused.png
void SetCanTickInEditor(bool Value)
void SetTickBeforeBeginPlay(bool Value)
images/classes/SMInstance/img/nd_img_SetTickBeforeBeginPlay.png
void SetTickInterval(float Value)
images/classes/SMInstance/img/nd_img_SetTickInterval.png
void SetAutoManageTime(bool Value)
images/classes/SMInstance/img/nd_img_SetAutoManageTime.png
bool CanAutoManageTime() const
images/classes/SMInstance/img/nd_img_CanAutoManageTime.png
float GetTickInterval() const
images/classes/SMInstance/img/nd_img_GetTickInterval.png
void SetStopOnEndState(bool Value)
images/classes/SMInstance/img/nd_img_SetStopOnEndState.png
bool GetStopOnEndState() const
images/classes/SMInstance/img/nd_img_GetStopOnEndState.png
bool IsInEndState() const
images/classes/SMInstance/img/nd_img_IsInEndState.png
void SetContext(UObject * Context)
images/classes/SMInstance/img/nd_img_SetContext.png
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
images/classes/SMInstance/img/nd_img_GetStateHistory.png
void SetStateHistoryMaxCount(int32 NewSize)
images/classes/SMInstance/img/nd_img_SetStateHistoryMaxCount.png
int32 GetStateHistoryMaxCount() const
images/classes/SMInstance/img/nd_img_GetStateHistoryMaxCount.png
void ClearStateHistory()
images/classes/SMInstance/img/nd_img_ClearStateHistory.png
void GetAllStateInstances(TArray< USMStateInstance_Base * > & StateInstances) const
images/classes/SMInstance/img/nd_img_GetAllStateInstances.png
void GetAllTransitionInstances(TArray< USMTransitionInstance * > & TransitionInstances) const
images/classes/SMInstance/img/nd_img_GetAllTransitionInstances.png
void SetNetworkInterface(TScriptInterface< ISMStateMachineNetworkedInterface > InNetworkInterface)
TScriptInterface< ISMStateMachineNetworkedInterface > GetNetworkInterface() const
images/classes/SMInstance/img/nd_img_GetNetworkInterface.png
void K2_TryGetNetworkInterface(TScriptInterface< ISMStateMachineNetworkedInterface > & Interface, bool & bIsValid)
images/classes/SMInstance/img/nd_img_K2_TryGetNetworkInterface.png
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
images/classes/SMInstance/img/nd_img_HasStarted.png
bool IsInitialized() const
images/classes/SMInstance/img/nd_img_IsInitialized.png
bool IsInitializingAsync() const
images/classes/SMInstance/img/nd_img_IsInitializingAsync.png
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
images/classes/SMInstance/img/nd_img_GetReferenceOwner.png
USMInstance * GetPrimaryReferenceOwner()
images/classes/SMInstance/img/nd_img_GetPrimaryReferenceOwner.png
TSubclassOf< USMStateMachineInstance > GetRootStateMachineNodeClass() const
images/classes/SMInstance/img/nd_img_GetRootStateMachineNodeClass.png
TSubclassOf< USMStateMachineInstance > GetStateMachineClass() const
void SetRootStateMachineNodeClass(TSubclassOf< USMStateMachineInstance > NewStateMachineNodeClass)
images/classes/SMInstance/img/nd_img_SetRootStateMachineNodeClass.png
void SetStateMachineClass(TSubclassOf< USMStateMachineInstance > NewStateMachineClass)
void OnPreStateMachineInitialized()
images/classes/SMInstance/img/nd_img_OnPreStateMachineInitialized.png
void OnStateMachineInitialized()
images/classes/SMInstance/img/nd_img_OnStateMachineInitialized.png
void OnStateMachineStart()
images/classes/SMInstance/img/nd_img_OnStateMachineStart.png
void OnStateMachineUpdate(float DeltaSeconds)
images/classes/SMInstance/img/nd_img_OnStateMachineUpdate.png
void OnStateMachineStop()
images/classes/SMInstance/img/nd_img_OnStateMachineStop.png
void OnStateMachineShutdown()
images/classes/SMInstance/img/nd_img_OnStateMachineShutdown.png
void OnStateMachineTransitionTaken(const FSMTransitionInfo & Transition)
images/classes/SMInstance/img/nd_img_OnStateMachineTransitionTaken.png
void OnStateMachineStateChanged(const FSMStateInfo & ToState, const FSMStateInfo & FromState)
images/classes/SMInstance/img/nd_img_OnStateMachineStateChanged.png
void OnStateMachineStateStarted(const FSMStateInfo & State)
images/classes/SMInstance/img/nd_img_OnStateMachineStateStarted.png
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
images/classes/SMInstance/img/nd_img_GetInputComponent.png
const TMap< FGuid, FSMGuidMap > & GetRootPathGuidCache() const
void SetRootPathGuidCache(const TMap< FGuid, FSMGuidMap > & InGuidCache)
TSharedPtr< FSMCachedPropertyData, ESPMode::ThreadSafe > GetCachedPropertyData()
TMap< FGuid, FSMExposedNodeFunctions > & GetNodeExposedFunctions()
void AddNonThreadSafeNode(FSMNode_Base * InNode)
FString GetRootNodeNameDefault()
FName GetStateMachineClassPropertyName()
FName GetInternalEventUpdateFunctionName()
FName GetInternalEvaluateAndTakeTransitionChainFunctionName()
FName GetInternalEventCleanupFunctionName()

Protected Functions

Name
void OnStateMachineInitialStateLoaded(const FGuid & StateGuid)
images/classes/SMInstance/img/nd_img_OnStateMachineInitialStateLoaded.png
virtual void OnStateMachineInitialStateLoaded_Implementation(const FGuid & StateGuid)
virtual void FinishInitialize()
bool HandleStopOnEndState()
virtual void CleanupAsyncObjects()
void CleanupAsyncInitializationTask()
virtual void Tick_Implementation(float DeltaTime)
virtual void OnPreStateMachineInitialized_Implementation()
virtual void OnStateMachineInitialized_Implementation()
virtual void OnStateMachineStart_Implementation()
virtual void OnStateMachineUpdate_Implementation(float DeltaSeconds)
virtual void OnStateMachineStop_Implementation()
virtual void OnStateMachineShutdown_Implementation()
virtual void OnStateMachineTransitionTaken_Implementation(const FSMTransitionInfo & Transition)
virtual void OnStateMachineStateChanged_Implementation(const FSMStateInfo & ToState, const FSMStateInfo & FromState)
virtual void OnStateMachineStateStarted_Implementation(const FSMStateInfo & State)
void Internal_Update(float DeltaSeconds)
bool Internal_EvaluateAndTakeTransitionChainByGuid(const FGuid & PathGuid)
void Internal_EventUpdate()
void Internal_EventCleanup(const FGuid & PathGuid)
void BuildStateMachineMap(FSMStateMachine * StateMachine)
void BuildStateMachineMap(FSMStateMachine * StateMachine, TSet< USMInstance * > & InstancesMapped)
bool CheckIsInitialized() const
void UpdateTime()
void RecordPreviousStateHistory(FSMState_Base * PreviousState)
void TrimStateHistory()

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

Name
TObjectPtr< USMStateMachineComponent > ComponentOwner
TScriptInterface< ISMStateMachineNetworkedInterface > NetworkInterface
TMap< FGuid, FSMNode_Base * > GuidNodeMap
TMap< FGuid, FSMState_Base * > GuidStateMap
TMap< FGuid, FSMTransition * > GuidTransitionMap
TSet< FGuid > StateMachineGuids
FSMStateMachine RootStateMachine
TObjectPtr< UObject > R_StateMachineContext
TObjectPtr< USMInstance > ReferenceOwner
TSubclassOf< USMStateMachineInstance > StateMachineClass
uint8 bAutoManageTime
uint8 bStopOnEndState
uint8 bCanEverTick
uint8 bCanTickInEditor
uint8 bCanTickWhenPaused
uint8 bTickRegistered
uint8 bTickBeforeInitialize
uint8 bTickBeforeBeginPlay
float TickInterval
float TimeSinceAllowedTick
float WorldSeconds
float WorldTimeDelta
TObjectPtr< UInputComponent > InputComponent
TEnumAsByte< ESMStateMachineInput::Type > AutoReceiveInput
int32 InputPriority
uint8 bBlockInput
TArray< FSMStateHistory > StateHistory
End Input.
int32 StateHistoryMaxCount
uint16 bEnableLogging
uint16 bLogStateChange
uint16 bLogTransitionTaken
uint16 bCanReplicateAsReference
uint16 bCallTickOnManualUpdate
uint16 bIsTicking
uint16 bIsUpdating
uint16 bCanEvaluateTransitionsLocally
uint16 bCanTakeTransitionsLocally
uint16 bCanExecuteStateLogic
uint16 bHasStarted
uint16 bLoadFromStatesCalled
uint16 bInitialized
uint16 bWaitingForStop
uint16 bIsStopping

Friends

Name
class USMStateMachineComponent

Public Functions Documentation

function USMInstance

USMInstance()

function Tick

void Tick(
    float DeltaTime
) override

images/classes/SMInstance/img/nd_img_Tick.png

The native tick is required to update the state machine.


function IsTickable

virtual bool IsTickable() const override

images/classes/SMInstance/img/nd_img_IsTickable.png


function IsTickableInEditor

virtual bool IsTickableInEditor() const override

function GetTickableTickType

virtual ETickableTickType GetTickableTickType() const override

function IsTickableWhenPaused

inline virtual bool IsTickableWhenPaused() const override

images/classes/SMInstance/img/nd_img_IsTickableWhenPaused.png


function GetTickableGameObjectWorld

virtual UWorld * GetTickableGameObjectWorld() const override

function GetStatId

virtual TStatId GetStatId() const override

function IsSupportedForNetworking

inline virtual bool IsSupportedForNetworking() const override

function GetLifetimeReplicatedProps

virtual void GetLifetimeReplicatedProps(
    TArray< FLifetimeProperty > & OutLifetimeProps
) const override

function BeginDestroy

virtual void BeginDestroy() override

function GetWorld

virtual UWorld * GetWorld() const override

function GetFunctionCallspace

virtual int32 GetFunctionCallspace(
    UFunction * Function,
    FFrame * Stack
) override

function CallRemoteFunction

virtual bool CallRemoteFunction(
    UFunction * Function,
    void * Parms,
    FOutParmRec * OutParms,
    FFrame * Stack
) override

function GetContext

virtual UObject * GetContext() const override

images/classes/SMInstance/img/nd_img_GetContext.png

The object which this state machine is running for.


function GetComponentOwner

inline USMStateMachineComponent * GetComponentOwner() const

images/classes/SMInstance/img/nd_img_GetComponentOwner.png

The component owning this instance. Will be null during initialization or if this state machine was created without a component.


function SetComponentOwner

inline void SetComponentOwner(
    USMStateMachineComponent * InComponent
)

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

virtual void Initialize(
    UObject * Context
) override

images/classes/SMInstance/img/nd_img_Initialize.png

Prepare the state machine for use.

Parameters:

Context
The context to use for the state machine.

function Start

virtual void Start() override

images/classes/SMInstance/img/nd_img_Start.png

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


function Update

virtual void Update(
    float DeltaSeconds =0.f
) override

images/classes/SMInstance/img/nd_img_Update.png

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


function Stop

virtual void Stop() override

images/classes/SMInstance/img/nd_img_Stop.png

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

virtual void Restart() override

images/classes/SMInstance/img/nd_img_Restart.png

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

virtual void Shutdown() override

images/classes/SMInstance/img/nd_img_Shutdown.png

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

void ReplicatedStart()

images/classes/SMInstance/img/nd_img_ReplicatedStart.png

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


function ReplicatedStop

void ReplicatedStop()

images/classes/SMInstance/img/nd_img_ReplicatedStop.png

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


function ReplicatedRestart

void ReplicatedRestart()

images/classes/SMInstance/img/nd_img_ReplicatedRestart.png

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


function StartWithNewContext

void StartWithNewContext(
    UObject * Context
)

images/classes/SMInstance/img/nd_img_StartWithNewContext.png

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


function EvaluateTransitions

void EvaluateTransitions()

images/classes/SMInstance/img/nd_img_EvaluateTransitions.png

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

bool EvaluateAndTakeTransitionChain(
    USMTransitionInstance * InFirstTransitionInstance
)

images/classes/SMInstance/img/nd_img_EvaluateAndTakeTransitionChain.png

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

bool EvaluateAndTakeTransitionChain(
    FSMTransition & InFirstTransition
)

function EvaluateAndFindTransitionChain

bool EvaluateAndFindTransitionChain(
    USMTransitionInstance * InFirstTransitionInstance,
    TArray< USMTransitionInstance * > & OutTransitionChain,
    USMStateInstance_Base *& OutDestinationState,
    bool bRequirePreviousStateActive =true
)

images/classes/SMInstance/img/nd_img_EvaluateAndFindTransitionChain.png

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

bool TakeTransitionChain(
    const TArray< USMTransitionInstance * > & InTransitionChain
)

images/classes/SMInstance/img/nd_img_TakeTransitionChain.png

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

void PreloadAllNodeInstances()

images/classes/SMInstance/img/nd_img_PreloadAllNodeInstances.png

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
)

images/classes/SMInstance/img/nd_img_SwitchActiveState.png

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
)

images/classes/SMInstance/img/nd_img_SwitchActiveStateByQualifiedName.png

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

inline bool HasPendingActiveStates() const

If there are states that need their active state changed.


function IsUpdating

inline bool IsUpdating() const

If this state machine instance is in an update cycle.


function IsStopping

inline bool IsStopping() const

images/classes/SMInstance/img/nd_img_IsStopping.png

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

void LoadFromState(
    const FGuid & FromGuid,
    bool bAllParents =true,
    bool bNotify =true
)

images/classes/SMInstance/img/nd_img_LoadFromState.png

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

void LoadFromMultipleStates(
    const TArray< FGuid > & FromGuids,
    bool bNotify =true
)

images/classes/SMInstance/img/nd_img_LoadFromMultipleStates.png

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

inline bool AreInitialStatesSetFromLoad() const

images/classes/SMInstance/img/nd_img_AreInitialStatesSetFromLoad.png

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

void ClearLoadedStates()

images/classes/SMInstance/img/nd_img_ClearLoadedStates.png

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

void K2_InitializeAsync(
    UObject * Context,
    FLatentActionInfo LatentInfo
)

images/classes/SMInstance/img/nd_img_K2_InitializeAsync.png

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

void CancelAsyncInitialization()

Attempt to cancel the async initialization task. This will perform a blocking wait for the task to finish if necessary.


function WaitForAsyncInitializationTask

void WaitForAsyncInitializationTask(
    bool bCallFinishInitialize =true
)

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

void TryGetNestedActiveState(
    FSMStateInfo & FoundState,
    bool & bSuccess
) const

images/classes/SMInstance/img/nd_img_TryGetNestedActiveState.png

Retrieve the lowest level single active state including all nested state machines. Returns read only information.


function GetSingleActiveState

FSMState_Base * GetSingleActiveState() const

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

FSMState_Base * GetSingleNestedActiveState() const

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

TArray< FSMState_Base * > GetAllActiveStates() const

Recursively retrieve all active states.


function GetSingleActiveStateGuid

FGuid GetSingleActiveStateGuid(
    bool bCheckNested =true
) const

images/classes/SMInstance/img/nd_img_GetSingleActiveStateGuid.png

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

void GetAllActiveStateGuids(
    TArray< FGuid > & ActiveGuids
) const

images/classes/SMInstance/img/nd_img_GetAllActiveStateGuids.png

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

TArray< FGuid > GetAllActiveStateGuidsCopy() const

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

USMStateInstance_Base * GetSingleActiveStateInstance(
    bool bCheckNested =true
) const

images/classes/SMInstance/img/nd_img_GetSingleActiveStateInstance.png

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

void GetAllActiveStateInstances(
    TArray< USMStateInstance_Base * > & ActiveStateInstances
) const

images/classes/SMInstance/img/nd_img_GetAllActiveStateInstances.png

Recursively retrieve all active state instances.

Parameters:

ActiveStateInstances
[Out] All active state instances. May be empty. Resets on method start.

function GetAllReferencedInstances

TArray< USMInstance * > GetAllReferencedInstances(
    bool bIncludeChildren =false
) const

images/classes/SMInstance/img/nd_img_GetAllReferencedInstances.png

Find all referenced instances. IncludeChildren will return all nested state machine references.


function GetStateMachinesWithReferences

TArray< FSMStateMachine * > GetStateMachinesWithReferences(
    bool bIncludeChildren =false
) const

Find all internal state machine structs which contain references.


function TryGetStateInfo

void TryGetStateInfo(
    const FGuid & Guid,
    FSMStateInfo & StateInfo,
    bool & bSuccess
) const

images/classes/SMInstance/img/nd_img_TryGetStateInfo.png

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

images/classes/SMInstance/img/nd_img_TryGetTransitionInfo.png

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


function GetReferencedInstanceByGuid

USMInstance * GetReferencedInstanceByGuid(
    const FGuid & Guid
) const

images/classes/SMInstance/img/nd_img_GetReferencedInstanceByGuid.png

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


function GetStateInstanceByGuid

USMStateInstance_Base * GetStateInstanceByGuid(
    const FGuid & Guid
) const

images/classes/SMInstance/img/nd_img_GetStateInstanceByGuid.png

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


function GetTransitionInstanceByGuid

USMTransitionInstance * GetTransitionInstanceByGuid(
    const FGuid & Guid
) const

images/classes/SMInstance/img/nd_img_GetTransitionInstanceByGuid.png

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


function GetNodeInstanceByGuid

USMNodeInstance * GetNodeInstanceByGuid(
    const FGuid & Guid
) const

images/classes/SMInstance/img/nd_img_GetNodeInstanceByGuid.png

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


function GetStateInstanceByQualifiedName

USMStateInstance_Base * GetStateInstanceByQualifiedName(
    const FString & InFullPath
) const

images/classes/SMInstance/img/nd_img_GetStateInstanceByQualifiedName.png

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

FSMState_Base * GetStateByGuid(
    const FGuid & Guid
) const

Quick lookup of a state by guid. Includes all nested.


function GetTransitionByGuid

FSMTransition * GetTransitionByGuid(
    const FGuid & Guid
) const

Quick lookup of any transition by guid. Includes all nested.


function GetNodeByGuid

FSMNode_Base * GetNodeByGuid(
    const FGuid & Guid
) const

Quick lookup of any node by guid. Includes all nested.


function FindStateByGuid

FSMState_Base * FindStateByGuid(
    const FGuid & Guid
) const

Linear search all state machines for a contained node.


function GetGuidRedirectMap

inline TMap< FGuid, FGuid > & GetGuidRedirectMap()

images/classes/SMInstance/img/nd_img_GetGuidRedirectMap.png

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


function SetGuidRedirectMap

inline void SetGuidRedirectMap(
    const TMap< FGuid, FGuid > & InGuidMap
)

images/classes/SMInstance/img/nd_img_SetGuidRedirectMap.png

Directly set the guid redirect map.


function GetRedirectedGuid

FGuid GetRedirectedGuid(
    const FGuid & InPathGuid
) const

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

inline FSMStateMachine & GetRootStateMachine()

The root state machine which may contain nested state machines.


function GetRootStateMachineNodeInstance

USMStateMachineInstance * GetRootStateMachineNodeInstance() const

images/classes/SMInstance/img/nd_img_GetRootStateMachineNodeInstance.png

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

bool IsActive() const

images/classes/SMInstance/img/nd_img_IsActive.png


function CanEverTick

inline bool CanEverTick() const

images/classes/SMInstance/img/nd_img_CanEverTick.png


function SetCanEverTick

void SetCanEverTick(
    bool Value
)

images/classes/SMInstance/img/nd_img_SetCanEverTick.png

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

inline bool IsTickRegistered() const

If the tick function has been registered.


function SetRegisterTick

void SetRegisterTick(
    bool Value
)

When false prevents the tick function from ever being registered. Can only be called along with initialize and cannot be changed.


function SetTickOnManualUpdate

void SetTickOnManualUpdate(
    bool Value
)

images/classes/SMInstance/img/nd_img_SetTickOnManualUpdate.png


function CanTickOnManualUpdate

inline bool CanTickOnManualUpdate() const

images/classes/SMInstance/img/nd_img_CanTickOnManualUpdate.png


function SetCanTickWhenPaused

void SetCanTickWhenPaused(
    bool Value
)

images/classes/SMInstance/img/nd_img_SetCanTickWhenPaused.png


function SetCanTickInEditor

void SetCanTickInEditor(
    bool Value
)

function SetTickBeforeBeginPlay

void SetTickBeforeBeginPlay(
    bool Value
)

images/classes/SMInstance/img/nd_img_SetTickBeforeBeginPlay.png


function SetTickInterval

void SetTickInterval(
    float Value
)

images/classes/SMInstance/img/nd_img_SetTickInterval.png

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


function SetAutoManageTime

void SetAutoManageTime(
    bool Value
)

images/classes/SMInstance/img/nd_img_SetAutoManageTime.png


function CanAutoManageTime

inline bool CanAutoManageTime() const

images/classes/SMInstance/img/nd_img_CanAutoManageTime.png


function GetTickInterval

inline float GetTickInterval() const

images/classes/SMInstance/img/nd_img_GetTickInterval.png


function SetStopOnEndState

void SetStopOnEndState(
    bool Value
)

images/classes/SMInstance/img/nd_img_SetStopOnEndState.png


function GetStopOnEndState

inline bool GetStopOnEndState() const

images/classes/SMInstance/img/nd_img_GetStopOnEndState.png


function IsInEndState

bool IsInEndState() const

images/classes/SMInstance/img/nd_img_IsInEndState.png

True if the root state machine is in an end state.


function SetContext

void SetContext(
    UObject * Context
)

images/classes/SMInstance/img/nd_img_SetContext.png

Sets a new context.


function GetNodeMap

const TMap< FGuid, FSMNode_Base * > & GetNodeMap() const

Get all mapped PathGuids to nodes.


function GetStateMap

const TMap< FGuid, FSMState_Base * > & GetStateMap() const

Get all mapped PathGuids to states.


function GetTransitionMap

const TMap< FGuid, FSMTransition * > & GetTransitionMap() const

Get all mapped PathGuids to transitions.


function GetStateHistory

const TArray< FSMStateHistory > & GetStateHistory() const

images/classes/SMInstance/img/nd_img_GetStateHistory.png

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


function SetStateHistoryMaxCount

void SetStateHistoryMaxCount(
    int32 NewSize
)

images/classes/SMInstance/img/nd_img_SetStateHistoryMaxCount.png

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

int32 GetStateHistoryMaxCount() const

images/classes/SMInstance/img/nd_img_GetStateHistoryMaxCount.png

Return the maximum history count.


function ClearStateHistory

void ClearStateHistory()

images/classes/SMInstance/img/nd_img_ClearStateHistory.png

Empty the state history array.


function GetAllStateInstances

void GetAllStateInstances(
    TArray< USMStateInstance_Base * > & StateInstances
) const

images/classes/SMInstance/img/nd_img_GetAllStateInstances.png

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

void GetAllTransitionInstances(
    TArray< USMTransitionInstance * > & TransitionInstances
) const

images/classes/SMInstance/img/nd_img_GetAllTransitionInstances.png

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

TScriptInterface< ISMStateMachineNetworkedInterface > GetNetworkInterface() const

images/classes/SMInstance/img/nd_img_GetNetworkInterface.png

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
)

images/classes/SMInstance/img/nd_img_K2_TryGetNetworkInterface.png

Return the server interface if there is one. This may be null. Always executes from the primary instance.


function TryGetNetworkInterface

ISMStateMachineNetworkedInterface * TryGetNetworkInterface() const

Return the network interface if it set and if networking is enabled. Always executes from the primary instance.


function UpdateNetworkConditions

void UpdateNetworkConditions()

Updates all needed nodes with the current network conditions. Best to be called after Initialization and before Start.


function CopyNetworkConditionsFrom

void CopyNetworkConditionsFrom(
    USMInstance * OtherInstance,
    bool bUpdateNodes =false
)

Copy network settings from the other instance.


function SetAllowTransitionsLocally

void SetAllowTransitionsLocally(
    bool bCanEvaluateTransitions,
    bool bCanTakeTransitions
)

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

void SetAllowStateLogic(
    bool bAllow
)

Notifies state machines if they are allowed to execute state logic locally.


function HasStarted

inline bool HasStarted() const

images/classes/SMInstance/img/nd_img_HasStarted.png

True if the instance has started.


function IsInitialized

inline bool IsInitialized() const

images/classes/SMInstance/img/nd_img_IsInitialized.png

If this instance is fully initialized.


function IsInitializingAsync

inline bool IsInitializingAsync() const

images/classes/SMInstance/img/nd_img_IsInitializingAsync.png

True only during async initialization.


function IsReferenceTemplate

bool IsReferenceTemplate() const

If this is an archetype object used as custom defaults for a reference.


function SetReferenceOwner

void SetReferenceOwner(
    USMInstance * Owner
)

Notify this instance is a reference owned by another instance.


function AddReplicatedReference

void AddReplicatedReference(
    const FGuid & PathGuid,
    USMInstance * NewReference
)

Record a reference to be replicated to the client.


function FindReplicatedReference

USMInstance * FindReplicatedReference(
    const FGuid & PathGuid
) const

Find a replicated reference by its path guid.


function GetReplicatedReferences

inline const TArray< FSMReferenceContainer > & GetReplicatedReferences() const

Return all references set to be replicated.


function HaveAllReferencesReplicated

bool HaveAllReferencesReplicated() const

Checks if all references on the primary instance have been received.


function CanReplicateAsReference

inline bool CanReplicateAsReference() const

If this instance is allowed to replicate if it is a reference.


function GetReferenceOwnerConst

inline const USMInstance * GetReferenceOwnerConst() const

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


function GetPrimaryReferenceOwnerConst

const USMInstance * GetPrimaryReferenceOwnerConst() const

Look up the owners to find the top-most instance.


function IsPrimaryReferenceOwner

inline bool IsPrimaryReferenceOwner() const

Check if this is the top most instance.


function GetReferenceOwner

inline USMInstance * GetReferenceOwner() const

images/classes/SMInstance/img/nd_img_GetReferenceOwner.png

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


function GetPrimaryReferenceOwner

USMInstance * GetPrimaryReferenceOwner()

images/classes/SMInstance/img/nd_img_GetPrimaryReferenceOwner.png

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


function GetRootStateMachineNodeClass

inline TSubclassOf< USMStateMachineInstance > GetRootStateMachineNodeClass() const

images/classes/SMInstance/img/nd_img_GetRootStateMachineNodeClass.png

The custom state machine node class assigned to the root state machine node.


function GetStateMachineClass

inline TSubclassOf< USMStateMachineInstance > GetStateMachineClass() const

Deprecated:

Use GetRootStateMachineNodeClass() instead.


function SetRootStateMachineNodeClass

inline void SetRootStateMachineNodeClass(
    TSubclassOf< USMStateMachineInstance > NewStateMachineNodeClass
)

images/classes/SMInstance/img/nd_img_SetRootStateMachineNodeClass.png

Sets the root state machine node class.

Parameters:

NewStateMachineNodeClass
The state machine node class to set.

function SetStateMachineClass

inline void SetStateMachineClass(
    TSubclassOf< USMStateMachineInstance > NewStateMachineClass
)

Deprecated:

Use SetRootStateMachineNodeClass() instead.


function OnPreStateMachineInitialized

void OnPreStateMachineInitialized()

images/classes/SMInstance/img/nd_img_OnPreStateMachineInitialized.png

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

void OnStateMachineInitialized()

images/classes/SMInstance/img/nd_img_OnStateMachineInitialized.png

Called when the instance is first initialized.


function OnStateMachineStart

void OnStateMachineStart()

images/classes/SMInstance/img/nd_img_OnStateMachineStart.png

Called right before the root state machine starts its initial state.


function OnStateMachineUpdate

void OnStateMachineUpdate(
    float DeltaSeconds
)

images/classes/SMInstance/img/nd_img_OnStateMachineUpdate.png

Called right before the root state machine updates.


function OnStateMachineStop

void OnStateMachineStop()

images/classes/SMInstance/img/nd_img_OnStateMachineStop.png

Called right after the instance has been stopped.


function OnStateMachineShutdown

void OnStateMachineShutdown()

images/classes/SMInstance/img/nd_img_OnStateMachineShutdown.png

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


function OnStateMachineTransitionTaken

void OnStateMachineTransitionTaken(
    const FSMTransitionInfo & Transition
)

images/classes/SMInstance/img/nd_img_OnStateMachineTransitionTaken.png

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


function OnStateMachineStateChanged

void OnStateMachineStateChanged(
    const FSMStateInfo & ToState,
    const FSMStateInfo & FromState
)

images/classes/SMInstance/img/nd_img_OnStateMachineStateChanged.png

Called when a state machine has switched states.


function OnStateMachineStateStarted

void OnStateMachineStateStarted(
    const FSMStateInfo & State
)

images/classes/SMInstance/img/nd_img_OnStateMachineStateStarted.png

Called when a state has started. This happens after OnStateMachineStateChanged and all previous transitions have evaluated.


function NotifyTransitionTaken

void NotifyTransitionTaken(
    const FSMTransition & Transition
)

Send transition events.


function NotifyStateChange

void NotifyStateChange(
    FSMState_Base * ToState,
    FSMState_Base * FromState
)

Send state change events.


function NotifyStateStarted

void NotifyStateStarted(
    const FSMState_Base & State
)

Send state started events.


function GetDebugStateMachine

inline FSMDebugStateMachine & GetDebugStateMachine()

function GetDebugStateMachineConst

inline const FSMDebugStateMachine & GetDebugStateMachineConst() const

function IsLoggingEnabled

inline bool IsLoggingEnabled() const

function RunUpdateAsReference

void RunUpdateAsReference(
    float DeltaSeconds
)

Call from an FSM reference. Avoids the update cancelling out if already in progress and keeps behavior consistent with normal nested FSMs.


function GetInputType

inline TEnumAsByte< ESMStateMachineInput::Type > GetInputType() const

Input.

Get the AutoReceiveInput type.


function GetInputPriority

inline int32 GetInputPriority() const

Get the input priority.


function GetBlockInput

inline bool GetBlockInput() const

Get the block input value.


function GetInputController

APlayerController * GetInputController() const

Attempt to find a valid player controller for this state machine. Requires input enabled and may return null.


function SetAutoReceiveInput

void SetAutoReceiveInput(
    ESMStateMachineInput::Type InInputType
)

Sets the auto receive input functionality. Should be done prior to initialization.


function SetInputPriority

void SetInputPriority(
    int32 InInputPriority
)

Sets the input priority. Should be done prior to initialization.


function SetBlockInput

void SetBlockInput(
    bool bNewValue
)

Sets the input priority. Should be done prior to initialization.


function GetInputComponent

inline UInputComponent * GetInputComponent() const

images/classes/SMInstance/img/nd_img_GetInputComponent.png

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

const TMap< FGuid, FSMGuidMap > & GetRootPathGuidCache() const

Retrieve the guid cache of all root FSMs and their contained nodes.


function SetRootPathGuidCache

void SetRootPathGuidCache(
    const TMap< FGuid, FSMGuidMap > & InGuidCache
)

Update the guid cache.


function GetCachedPropertyData

TSharedPtr< FSMCachedPropertyData, ESPMode::ThreadSafe > GetCachedPropertyData()

Retrieve the cached property data which is only needed during initialization. If called after initialization the cache may be recalculated.


function GetNodeExposedFunctions

inline TMap< FGuid, FSMExposedNodeFunctions > & 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

void AddNonThreadSafeNode(
    FSMNode_Base * InNode
)

Signal a node isn't thread safe to prevent it from loading async.


function GetRootNodeNameDefault

static inline FString GetRootNodeNameDefault()

The default root node name to assign. Should never be changed.


function GetStateMachineClassPropertyName

static inline FName GetStateMachineClassPropertyName()

The name of the StateMachineClass property, which represents the RootStateMachineNodeClass.


function GetInternalEventUpdateFunctionName

static inline FName GetInternalEventUpdateFunctionName()

function GetInternalEvaluateAndTakeTransitionChainFunctionName

static inline FName GetInternalEvaluateAndTakeTransitionChainFunctionName()

function GetInternalEventCleanupFunctionName

static inline FName GetInternalEventCleanupFunctionName()

Protected Functions Documentation

function OnStateMachineInitialStateLoaded

void OnStateMachineInitialStateLoaded(
    const FGuid & StateGuid
)

images/classes/SMInstance/img/nd_img_OnStateMachineInitialStateLoaded.png

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

virtual void OnStateMachineInitialStateLoaded_Implementation(
    const FGuid & StateGuid
)

function FinishInitialize

virtual void FinishInitialize()

Called after Initialize sequence completed for methods that must run on the GameThread.


function HandleStopOnEndState

bool HandleStopOnEndState()

Check if in an end state and stop.

Return: true if stopped.


function CleanupAsyncObjects

virtual void CleanupAsyncObjects()

Async objects need their async flags removed so they can be garbage collected.


function CleanupAsyncInitializationTask

void CleanupAsyncInitializationTask()

Wait for the async task to complete and free memory on completion.


function Tick_Implementation

virtual void Tick_Implementation(
    float DeltaTime
)

function OnPreStateMachineInitialized_Implementation

inline virtual void OnPreStateMachineInitialized_Implementation()

function OnStateMachineInitialized_Implementation

inline virtual void OnStateMachineInitialized_Implementation()

function OnStateMachineStart_Implementation

inline virtual void OnStateMachineStart_Implementation()

function OnStateMachineUpdate_Implementation

inline virtual void OnStateMachineUpdate_Implementation(
    float DeltaSeconds
)

function OnStateMachineStop_Implementation

inline virtual void OnStateMachineStop_Implementation()

function OnStateMachineShutdown_Implementation

inline virtual void 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

inline virtual void OnStateMachineStateStarted_Implementation(
    const FSMStateInfo & State
)

function Internal_Update

void Internal_Update(
    float DeltaSeconds
)

Internal update logic. Can be called during an update and used by event triggers.


function Internal_EvaluateAndTakeTransitionChainByGuid

bool Internal_EvaluateAndTakeTransitionChainByGuid(
    const FGuid & PathGuid
)

Internal logic for taking a transition chain by the path guid.


function Internal_EventUpdate

void Internal_EventUpdate()

Internal logic from when an auto-bound event might trigger an update.


function Internal_EventCleanup

void Internal_EventCleanup(
    const FGuid & PathGuid
)

Internal cleanup logic after an auto-bound event fires.


function BuildStateMachineMap

void BuildStateMachineMap(
    FSMStateMachine * StateMachine
)

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

bool CheckIsInitialized() const

Logs a warning if not initialized.


function UpdateTime

void UpdateTime()

Records time running so delta time can be established if not ticking or providing accurate delta seconds.


function RecordPreviousStateHistory

void RecordPreviousStateHistory(
    FSMState_Base * PreviousState
)

Record the given state into the state history.


function TrimStateHistory

void TrimStateHistory()

Makes sure state history current count doesn't exceed max count.


Public Attributes Documentation

variable RootStateMachineGuid

FGuid RootStateMachineGuid;

Used to identify the root state machine during initialization. This is not a calculated value and represents the NodeGuid.


variable OnPreStateMachineInitializedEvent

FOnStateMachineInitializedSignature 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

FOnStateMachineInitializedSignature OnStateMachineInitializedEvent;

Called when the state machine is first initialized.


variable OnStateMachineStartedEvent

FOnStateMachineStartedSignature OnStateMachineStartedEvent;

Called right before the state machine is started.


variable OnStateMachineUpdatedEvent

FOnStateMachineUpdatedSignature OnStateMachineUpdatedEvent;

Called right before the state machine is updated.


variable OnStateMachineStoppedEvent

FOnStateMachineStoppedSignature OnStateMachineStoppedEvent;

Called right after the state machine has ended.


variable OnStateMachineShutdownEvent

FOnStateMachineShutdownSignature OnStateMachineShutdownEvent;

Called right after the state machine has shutdown.


variable OnStateMachineTransitionTakenEvent

FOnStateMachineTransitionTakenSignature OnStateMachineTransitionTakenEvent;

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


variable OnStateMachineStateChangedEvent

FOnStateMachineStateChangedSignature OnStateMachineStateChangedEvent;

Called when a state machine has switched states.


variable OnStateMachineStateStartedEvent

FOnStateMachineStateStartedSignature OnStateMachineStateStartedEvent;

Called when a state has started. This happens after OnStateMachineStateChanged and all previous transitions have evaluated.


variable ReferenceTemplates

TArray< TObjectPtr< UObject > > ReferenceTemplates;

Protected Attributes Documentation

variable ComponentOwner

TObjectPtr< USMStateMachineComponent > ComponentOwner;

The component owning this instance.


variable NetworkInterface

TScriptInterface< ISMStateMachineNetworkedInterface > NetworkInterface;

Pointer to server object to notify of active transitions.


variable GuidNodeMap

TMap< FGuid, FSMNode_Base * > GuidNodeMap;

Flattened map of all node Path Guids -> Node references


variable GuidStateMap

TMap< FGuid, FSMState_Base * > GuidStateMap;

Flattened map of all state Path Guids -> State references.


variable GuidTransitionMap

TMap< FGuid, FSMTransition * > GuidTransitionMap;

Flattened map of all transition Path Guids -> Transition references.


variable StateMachineGuids

TSet< FGuid > StateMachineGuids;

Map of all StateMachine Path Guids


variable RootStateMachine

FSMStateMachine RootStateMachine;

Top level state machine


variable R_StateMachineContext

TObjectPtr< UObject > R_StateMachineContext;

The context to run the state machine in.


variable ReferenceOwner

TObjectPtr< USMInstance > ReferenceOwner;

If this instance is owned by another instance making this a reference.


variable StateMachineClass

TSubclassOf< USMStateMachineInstance > 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

uint8 bAutoManageTime;

Automatically calculate delta seconds if none are provided. Requires context with a valid World.


variable bStopOnEndState

uint8 bStopOnEndState;

Should this instance stop itself once an end state has been reached. An Update call is required for this to occur.


variable bCanEverTick

uint8 bCanEverTick;

Should this instance tick. By default it will update the state machine.


variable bCanTickInEditor

uint8 bCanTickInEditor;

Should this instance tick in editor.


variable bCanTickWhenPaused

uint8 bCanTickWhenPaused;

Should this instance tick when the game is paused.


variable bTickRegistered

uint8 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

uint8 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

uint8 bTickBeforeBeginPlay;

When false IsTickable checks if the world has started play.


variable TickInterval

float 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

float TimeSinceAllowedTick = 0.f;

Time since the last valid tick occurred.


variable WorldSeconds

float WorldSeconds = 0.f;

variable WorldTimeDelta

float WorldTimeDelta = 0.f;

variable InputComponent

TObjectPtr< UInputComponent > InputComponent;

variable AutoReceiveInput

TEnumAsByte< ESMStateMachineInput::Type > 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

int32 InputPriority;

The priority of this input component when pushed in to the stack.


variable bBlockInput

uint8 bBlockInput;

Whether any components lower on the input stack should be allowed to receive input.


variable StateHistory

TArray< FSMStateHistory > StateHistory;

End Input.

Ordered history of states, oldest to newest, not including active state(s).


variable StateHistoryMaxCount

int32 StateHistoryMaxCount = 20;

The total number of states to keep in history. Set to -1 for no limit.


variable bEnableLogging

uint16 bEnableLogging;

Enable info logging for the state machine.


variable bLogStateChange

uint16 bLogStateChange;

Log when a state change occurs. This includes when a state machine starts or exits where transitions won't apply.


variable bLogTransitionTaken

uint16 bLogTransitionTaken;

Log whenever a transition occurs.


variable bCanReplicateAsReference

uint16 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

uint16 bCallTickOnManualUpdate;

The Update method will call Tick only if Update was not called by native Tick.


variable bIsTicking

uint16 bIsTicking;

True if currently ticking.


variable bIsUpdating

uint16 bIsUpdating;

True if currently updating.


variable bCanEvaluateTransitionsLocally

uint16 bCanEvaluateTransitionsLocally;

Should this instance be allowed to process transitions.


variable bCanTakeTransitionsLocally

uint16 bCanTakeTransitionsLocally;

Should this instance take transitions or only notify the server.


variable bCanExecuteStateLogic

uint16 bCanExecuteStateLogic;

Should this instance be allowed to execute state logic.


variable bHasStarted

uint16 bHasStarted;

True once the instance has started.


variable bLoadFromStatesCalled

uint16 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

uint16 bInitialized;

Signal the state machine has been initialized. Normally set automatically when calling Initialize().


variable bWaitingForStop

uint16 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

uint16 bIsStopping;

If the state machine instance is currently stopping.


Private Attributes Documentation

variable StatesPendingActivation

TArray< FSMState_Base * > 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

FDelegateHandle OnPreGarbageCollectHandle;

variable AsyncInitializationTask

TUniquePtr< FAsyncTask< FInitializeInstanceAsyncTask > > AsyncInitializationTask;

The async initialization task.


variable OnStateMachineInitializedAsyncDelegate

FOnStateMachineInstanceInitializedAsync OnStateMachineInitializedAsyncDelegate;

Set from caller of initialize async function.


variable OnReferencesReplicatedEvent

FOnReferencesReplicated OnReferencesReplicatedEvent;

variable ReplicatedReferences

TArray< FSMReferenceContainer > ReplicatedReferences;

Set at initialization time on the primary instance, containing all nested references. Used for reference replicated variables.


variable bInitializingAsync

uint16 bInitializingAsync;

True only during async initialization.


variable PathGuidRedirectMap

TMap< FGuid, FGuid > 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

TMap< FGuid, FSMGuidMap > 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

TSharedPtr< FSMCachedPropertyData, ESPMode::ThreadSafe > CachedPropertyData;

Cached property data for this state machine instance. Once mapped it includes properties of this instance and all contained node classes.


variable NodeExposedFunctions

TMap< FGuid, FSMExposedNodeFunctions > NodeExposedFunctions;

variable NonThreadSafeNodes

TArray< FSMNode_Base * > NonThreadSafeNodes;

variable CriticalSection

FCriticalSection CriticalSection;

variable DebugStateMachine

FSMDebugStateMachine DebugStateMachine;

Friends

friend USMStateMachineComponent

friend class USMStateMachineComponent(
    USMStateMachineComponent 
);