Finite State Machine {{ currentPage ? currentPage.title : "" }}

2.1 Creating an FSM

To create an FSM you can just right click in content browser and select AscentToolset->Ascent FSM. Clicking on the newly create asset will allow you to edit the FSM. 

2.2 Starting an FSM

To start an FSM you need to add the UASMFSMComponent to any actor of your choice and then set the newly created FSM in the Property Editor. Then you just have to call the StartFSM Node from the component.

2.3 Editing the FSM

Double clicking on the newly created FSM asset you can start using the graph editor. Right-clicking in the graph editor you should be able to create new nodes: 

ASMStartFSMNode: Identifies the actual first node to be executed for this FSM. 

ASMStateNode: A generic node that can be bound to an FSM State. 

Clicking on one of the node on the right you can edit his Properties. 

The first and most important thing to setup is the actual class of the FSMState to be instanced (click on blank space to see general settings). The FSM will not work if their states are not correctly set and nothing will be triggered if an invalid class is set. FSMStates Properties can also be configured throught the graph editor. 

Once you place one or more node you can create Transitions by just dragging out an edge from whatever node. Also Transitions needs to be configured. They are identified throught GameplayTags. If you are new to GameplayTags check Chapter 2.2 of this document and Unreal Engine Official Documentation. 

To move from one FSM State to another you need to call the TriggerTransition node from the FSMComponent or directly from the FSMState. If an output Transition with that matches the provided tag is found among the output transitions of the Current State, the FSM will move to the next state. OnExit will be called on the current state, OnTransition and OnEnter will be called in the following state. 

2.4 FSM States

To create an FSM State you actually need to create a new Blueprint Class (or C++) that inherits from ASMBaseFSMState. Inside the state there are set of virtual methods you can Implement: 

OnEnter: Called once the state becomes the CurrentState in the FSM

OnExit: Called once a transition is accepted and another state is going to become the new CurrentState

OnUpdate: Called every tick if CanFSMTick is checked in the owner FSM component

OnTransition: Called before OnEnter providing a pointer to the previous state. Useful to check some data during the transition. 

2.5 Transitions 

Transition can be triggered locally with the TriggerTransition node or in all the instances in a multiplayer match with the SynchedTriggerTransition version, that will dispatch the transition to all the clients. 

You can also setup Transition Conditions by creating subclasses of AGSCondition and implementing the VerifyCondition method. In that case the transition will be performed only if all the conditions are verified.

{{{ content }}}