UFSM: Finite State Machine

@JGagner

So, I came up with this, for the next update of the plugin…

There’s some new function nodes which you can explicitly control the behaviour of transition rules when calling “Set State” in the FSM Component.
They take a ‘FSM Transition’ enum as input; The FSM will only exit previous State and activate the one you called only if the transition value is ‘Succeeded’:

In case your condition fails, the FSM keeps going without running any Enter/Exit triggers, like in my game project’s example here:

The ‘Evaluate’ or ‘Eval (…)’ nodes are utility functions I have added to compact the check of values and output of a FSM Transition enum, to avoid spaghetti by replacing the use of Branch nodes and Set Enum Value nodes altogether, these are included in a new Blueprint Function Library added to the plugin:

I’ll send these changes to Epic next monday, cheers.

Wow, these are perfect! Thank you so much :slight_smile:

The update with nodes above is now live on Marketplace (1.6.5 for UE4.15 and UE4.16)

Once again, great plugin! Super easily expandable and keeps my blueprints very tidy. Check out feature preview video of Third Person Controller that I’ve created using ufsm: Third Person Gravity Controller v0.1 Features Preview (Unreal Engine) - YouTube

This is awesome!
Great work, these types of interactions and gravity changes are quite complex stuff to do, well done :slight_smile:

Sigh… Suddenly photobucket decided to charge $400 to host images (which was free until a day ago)… now I’ll have to migrate all screengrabs related to Unreal to another free host, this is going to take a while :confused:

So after some digging and a few hours of effort I got a successful compile, I am trying to integrate UFSM into an existing project, which took some digging to find that I have to create a new c++ class in my project to activate the plug in…

My problem now is that I cannot get the AddDynamic functions to call when I change the state… I have everything create and assigned…and compiles ok… no issues in the log…

Contructor…
{
m_FSM_WeaponState = PCIP.CreateDefaultSubobject<UStateMachineComponent>(this, TEXT(“Weapon State Machine”));

m_FSM_WeaponState->AddState(0, FName(“Add Weapon”));

m_FSM_WeaponState-&gt;GetState(0)-&gt;OnBeginState.AddDynamic(this, &AR_Weapon::FSM_OnBeginAdd);

}

BeginPlay
{
m_FSM_WeaponState->SetActive(true, false);
}

Problem is when I use the SetState(0) the bind functions are not getting called…

As a side not very little info on using this plug in in C++

I have resolved this issue - thanks

UFSM 1.6.5 has been updated to Unreal 4.17 and is already available for Gumroad owners;
Marketplace update will take a few days for Epic to process.

Hi. So it’s been two weeks already and still no updates on the marketplace :frowning: . Any news?

Unfortunately no answer and no updates yet. Sorry!

Epic just released plugin for Unreal 4.17 today.

Interesting plugin! Some questions (maybe stupid):

  1. Can you have a main BP with all of the states configured and override the behavior for each state in child BPs?
  2. Can you call a different named state on a different BP? (example: hit state for yourself and take damage state for enemy)
  3. Can you check if a certain state exists and if it doesn’t trigger a fallback state? If the answer to 1. was “yes” I guess you could override the state in the called state to another state that was actually implemented.

You can override the “OnEnterXX”, “OnUpdateXX” and “OnExitXX” functions generated on parent BP class.
Where “XX” is name of your state.

To set State of another BP you have to get a reference to it and grab its FSM Component then call “Set State” or “Set State (conditional)” on it.

Whenever you try to set FSM to a State that doesn’t exist, the “Aborted” pin on the Node will execute. From there you can react accordingly.

Great, thanks! :smiley:

I will submit soon 1.6.6 update; In details panel of a FSM Component you’ll be able to set by name an option for the starting State you want the FSM to set by default before “Begin Play”:

You can also set its value in C++ code:



MyFSM->StartupState = FName("Jump");


Hey [USER=“434”][/USER], I just bought UFSM and I’m excited to see what it can do for my project. Unfortunately, useful documentation for using UFSM in C++ is nonexistent. Do you have any example projects, code, or tutorials on how to use this plugin in C++? I can’t even figure out how to properly setup the component, much less use it. Also C++ usage of this plugin varies from the wiki to your post here, and somebody above mentioned the need to create a new class to activate the plugin. What kind of class? A subclass of the state machine component? What do you write in the FSM component vs the character? Is that even necessary? How the heck do you use this thing? I really need a clear and full (as in complete and working class files, not a couple .cpp file snippets) example of the correct way to use this asset as it was intended.

The main reason I don’t publish larger systems I’ve developed for Unreal is exactly for the lack of time available to create feature complete documentation.

I focus more on Blueprint support because that is what the majority use. The UFSM Component is so small that a C++ programmer will read through the code in one coffee then be ready to go, every field in the Component has concise comments; Blueprint developers however require more attention as they usually have no programming background.

And as you said, systems change under the hood for C++ developers quite often while for Blueprint users they remain the same, rendering a necessity to constantly reconstruct C++ documentation.

What I can do in the near future to compensate this is publish more material to the Marketplace such as Characters (from personal canceled project) with C++ Controllers and A.I code that fellow C++ developers can take as basis for study and starting point for they own Character Controllers.
Unfortunately, for the low price this plugin is offered, I cannot afford the time or money to constantly create dedicated free documentation and free demos for every time the tool evolves. I’d have to quit my job for that and the Marketplace isn’t profitable to allow me to do such a move.

Well then I’d at least expect you to update the description of the product instead of leaving links up to outdated and incomplete information claiming “setting up a complex FSM within a C++ Class is as simple as creating sub-objects”. You provide a couple of oversimplified screenshots worth of code suggesting how easy it is to setup, but it’s false advertising. The example code given doesn’t work anymore and you seriously provide no attempt in updating it at all? I’ve seen larger open source projects with better support and documentation maintenance. There is an expected level of support that comes with a product you pay for, and it’s certainly much better than this. At least be forward in telling people that you don’t provide any support for C++ programmers instead of making it seem like it’s easy to use.

Many C++ programmers are using it without issues; you are the first to say you can’t create a sub class of the UFiniteStateMachine component and use its functions. The way to add States to the FSM through C++ code hasn’t changed at all, it’s still the same from the wiki example.
The only major change was the event subscription mechanism described on the post you linked yourself.
​​
Btw, I’ve just added that code example from the forum post to the Wiki page.