UFSM: Finite State Machine

I don’t know how the FSM works. I expect the state node is an object(not just an enum value) that can response events routed from the host object, it binds the events interested from the host object when entering. Also, the state transition should be an object that can response active event when the connected node entering, then it can bind events interested (avoid adding unnecessary temporary variables) from other systems for the transition detecting.

The FSM is a network replicated Component.
It’s not a hierarchy of UObjects.

Hi,

Thanks for developing this - just purchased it last night.

Few ?s:

  • Are sub-state machines supported? I’m using this for an ability system, and want to have several sub-state machines, 1 for each ability the character can execute
  • If not, what’s the best approach? Should I make an array of state machines, and just disable any of them that I’m not currently using?

​There’s no need to have hierarchical FSM because you can attach multiple FSM Components (without auto activate) then use the “Go To FSM” to transition between multiple FSMs.
[HR][/HR]
By the way, since last month I have an update where the “Unchecked” output pin is removed, I’ve refactoring a lot the internals to just return “Abort” instead, when something is cancelled.

I didn’t publish it because this update breaks compatibility with existing projects. Would be up to you guys to decide if I should make that update available or not…

Submitted 4.22 version for review.

Submitted v2.1.0 for Unreal 4.22+

WARNING!!!

  • “UNCHECKED” pin has been removed!
  • I do not recommend upgrading to UFSM 2.1+ in middle of a project, you might have to fix a lot of Blueprint errors if you use the removed “Unchecked” pin for anything (i.e, runtime states generation)

Hello Bruno,
Just updated the plugin after using it for a while and loving it.

Building the FSM in C++ from pawn constructor using the first post code example, i now trigger the error :


[2019.05.17-12.18.41:513][183]FSMs: Error: [StateMachine]: 'New States' Array is zero sized.
[2019.05.17-12.18.41:513][183]PIE: Error: {FSM}:: 'New States' Array is zero sized. -->  FSM: Make States: Function /Script/UFSM.StateMachineComponent:MakeStates at (ShooterPlayerStateMachine /Game/Maps/UEDPIE_0_Highrise.Highrise:PersistentLevel.

Weirdest part is that the FSM is working.

@MaximeDupart

Oh you say example from first page, that is outdated from plugin 1.x version.

There’s a more up to date example here:
https://forums.unrealengine.com/unreal-engine/marketplace/88276-ufsm-finite-state-machine?p=991640#post991640

Perfect, thanks !

where’s the new example project?

Demo projects can be upgraded by users, right click uproject file and migrate to latest engine version.

how to fix the “Unchecked” error?

Any function trying to access the removed enum item have to be edited to return a valid value from the menu dropdown.
If it’s an empty state function I would just delete the function instead then recompile the Blueprint.

Hi… Thanks for your support
I’m still getting the ‘State ID doesn’t exist’ error when I try to add new states…
I can’t add new states after ‘Rollattack’ state in the photo above… what should I do??
My UFSM plugin version is 2.1.1

You probably made changes to the instance of your fsm Blueprint then you made changes to the default asset of your fsm Blueprint.

Now your state lists are different.
You should make changes to list in your fsm Blueprint only. I only made it to “Edit Anywhere” because of a editor bug (I see I must make it defaults only again to avoid this user confusion).


I’m working on v3.0 so any changes to that is probably coming only in v3 update.
(this is fixed on v3, I have no ETA when it will be ready tho)

Due to requests, in v3 I’m bringing back hierarchical FSMs, but in a “reactive” model (it’s very similar to the way Unity’s PlayMaker works), action-based.

This “Reactive Hierarchical State Machine” model is target for gameplay graphs (Blueprints) and isn’t very C++ friendly to use (although it’s still doable to implement it in pure code classes);
These nodes can be integrated with the existing FSM Component and can also have nested FSM graphs that can work as a hierarchy of FSMs to have an effective hierarchical state machine solution with editable graphs for each “Action”. (I’ve put a lot of effort to design a system that won’t cause infinite loops independent of whatever craziness you do with it)

The concept is very simple: you can create (R)FSM classes and attach them to a node, each can host how many “Actions” you need which you can also create a Blueprint graph for.
Once a FSM node is entered by your exec pins, it becomes active and starts executing it’s stack of actions every frame until make the FSM exit its state:


[HR][/HR]
I will also submit the usual demo project for reference, once the update arrives, this is the whole graph for the demo controller:


[HR][/HR]

v3.0 released for Unreal 4.24+, you can find updated demo project here:
UFSM_3.0.0_UE4.24_Demo.zip

hi, Is there a full c++ example?
I m looking at just a swing door demo (open, opening, close, closing, locked)

I have the states defined. I understand the begin, update, end (= StateMachineBehavior in unity)
but I am a bit confused on how to set up the state transition

There’s this example in demo project (zip above)
https://forums.unrealengine.com/unreal-engine/marketplace/88276-ufsm-finite-state-machine?p=991640#post991640

Thanks. I tried to run this code.
I have created a Character Test_Native which extends FSM_NativeCharacter. I then placed it in the map.
I don’t see the output log "BINDED Begin!’.
In my project, I have not been able to bind function either. It looks like OnInitializedFSM_implementation is not called

update: I found din Q/A to use PostInitializeComponents and it’s working



void ASwingDoor::PostInitializeComponents()
{

    Super::PostInitializeComponents();

    StateMachine->GetState(1)->OnUpdateState.AddDynamic(this, &ASwingDoor::OpenDoor);
    StateMachine->GetState(3)->OnUpdateState.AddDynamic(this, &ASwingDoor::CloseDoor);
}


Is there a way to use the *StateMachine *component within ASwingDoor::OpenDoor()
For example, OpenDoor() is slowly *Opening *the door. Once the door is opened, it is setting the *Closed *state or end the current state