Announcement

Collapse
No announcement yet.

UFSM: Finite State Machine

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • started a topic [RELEASED] UFSM: Finite State Machine

    UFSM: Finite State Machine


    [Now available on Unreal Marketplace]

    ----------

    Hello guys! I've got something for you
    Due to the fact Unreal Engine 4's programming environment doesn't implement a FSM for us to use in code, like in previous versions, for some projects I felt compelled to kick in and implement it by myself then...
    I've developed a Plugin module which adds to the UE4 environment a bunch of functionality regarding FSMs, so then I could stop trying to address a bazillion 'If Then Elses' everywhere.

    I haven't published this yet, but as always, I believe this may be useful for many other Unreal developers so I'm posting to share. Would anybody be interested in this, a FSM Component which allows you to use AnimGraph's State Machines as visual editors?!
    I like to use the AnimGraph because it feels like I'm using Unity PlayMaker inside Unreal

    Btw, it can be used not just within Animation Graphs, it's very integrated with C++ API, Blueprint nodes, Behaviour Tree nodes, giving us many 'ins and outs' to access the same FSM Component.
    Here a few features already implemented and working well:



    * Blueprintable Finite State Machine System.
    * Blueprint Actor Component Based.
    * Event-Based Tasks/Actions can be Broadcasted.
    * Supports Enumerators as State ID.
    * Supports Runtime State-Machine Creation/Deletion.
    * Supports Runtime State-Machine Event Bindings.
    * State Machines can Tick and Track Update Time.
    * FSM Properties can be Replicated.
    * Get/Set States from C++, Blueprints, Animation Graphs, Behavior Trees.




    Here's some screenies:


    [Create a new FSM Component, right click Asset Browser]:





    [We simply add to the Actor the FSM Component]:



    [As of 1.3+ version: "Auto Activate" must be checked to activate FSM Component]



    [Then we can edit the FSM's States from an Animation Blueprint's State Machine, like this simple one]:






    [Or manipulate States from a Behavior Tree too]:






    [Or we can Read/Write FSM States from Blueprint Graphs]:






    [Or we can build a Finite State Machine in C++ Constructor, from scratch ]:



    [As of 1.3+ version: StateMachine->SetActive(true,false); is also required to activate FSM Component]



    ------------------------------


    [We can now spawn a custom Editor Graph which automatically generates a visual tree representation of your UComponent's States, for both HFSM and FSM types]:







    ------------------------------

    You can read some more details about it HERE ( https://brunoxavierleite.com/2016/07...state-machine/ )
    If you guys have interest, I submit this to Epic to have this little guy in Launcher's Plugin section (~$10 Obamas)

    ------------------------------

    TUTORIAL AND DEMO PROJECT

    Last edited by BrUnO XaVIeR; 06-30-2017, 02:29 AM.

  • replied
    Originally posted by jm991 View Post
    Hi,

    * 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.


    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..

    Leave a comment:


  • replied
    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?

    Leave a comment:


  • replied
    The FSM is a network replicated Component.
    It's not a hierarchy of UObjects.

    Leave a comment:


  • replied
    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.

    Leave a comment:


  • replied
    Originally posted by BrUnO XaVIeR View Post
    I'm not hot-reload user (there's only one plugin I use hot-reloading with) so I'm not sure...
    But with hot-reloading shouldn't you move plugins from Marketplace folder to your project folder to make it work properly?

    I'm in the dark just like you on this one, but I would give that a try.
    No problem! I have everything moved over to my project folder already, as I do with all plugins. I'll keep an eye on it, just wanted to see if you possibly knew anything.

    Thanks for the response! (:

    Leave a comment:


  • replied
    I'm not hot-reload user (there's only one plugin I use hot-reloading with) so I'm not sure...
    But with hot-reloading shouldn't you move plugins from Marketplace folder to your project folder to make it work properly?

    I'm in the dark just like you on this one, but I would give that a try.

    Leave a comment:


  • replied
    I haven't done much research into this issue because I haven't had time, but lately I've been running into this whenever I hot reload my project. I get the error the next time I launch. I can clear it if I do a rebuild (as the compiler sees the old hot reload files, and removes them) but yeah. It's been killing my workflow lately having to rebuild every time I do a hot reload and relaunch the editor.

    Code:
    Assertion failed: GIsHotReload [File:D:\Build\++UE4\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectBase.cpp] [Line: 606] 
    Trying to recreate class 'UFSMInterface' outside of hot reload!
    
    
    Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x00000098
    
    0x00007ffbb7580f31 UE4Editor-CoreUObject.dll!IncrementalPurgeGarbage() [d:\build\++ue4\sync\engine\source\runtime\coreuobject\private\uobject\garbagecollection.cpp:1113]
    0x00007ffbb763f50f UE4Editor-CoreUObject.dll!StaticExit() [d:\build\++ue4\sync\engine\source\runtime\coreuobject\private\uobject\obj.cpp:4304]
    0x00007ffbb7440a57 UE4Editor-CoreUObject.dll!TBaseStaticDelegateInstance<void __cdecl(void)>::ExecuteIfSafe() [d:\build\++ue4\sync\engine\source\runtime\core\public\delegates\delegateinstancesimpl.h:788]
    0x00007ff62d2d0134 UE4Editor.exe!TBaseMulticastDelegate<void>::Broadcast() [d:\build\++ue4\sync\engine\source\runtime\core\public\delegates\delegatesignatureimpl.inl:937]
    0x00007ff62d2cffb6 UE4Editor.exe!FEngineLoop::AppPreExit() [d:\build\++ue4\sync\engine\source\runtime\launch\private\launchengineloop.cpp:4231]
    0x00007ff62d2d50af UE4Editor.exe!FEngineLoop::Exit() [d:\build\++ue4\sync\engine\source\runtime\launch\private\launchengineloop.cpp:3017]
    0x00007ff62d2d5b71 UE4Editor.exe!GuardedMain() [d:\build\++ue4\sync\engine\source\runtime\launch\private\launch.cpp:177]
    0x00007ff62d2d5bba UE4Editor.exe!GuardedMainWrapper() [d:\build\++ue4\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:144]
    0x00007ff62d2e3dac UE4Editor.exe!WinMain() [d:\build\++ue4\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:223]
    0x00007ff62d2e5aaa UE4Editor.exe!__scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:283]
    0x00007ffbffc67e94 KERNEL32.DLL!UnknownFunction []
    0x00007ffc01b5a251 ntdll.dll!UnknownFunction []
    It did not used to do this... However it's been so long, I have no idea what I might have done to cause it. Any help is appreciated (:

    Leave a comment:


  • replied
    Sounds like you have copied those Blueprints from another project and they are just corrupted files.

    Leave a comment:


  • replied
    Oh wait, the problem is way more complex than that actually, and I can't seem to be able to fix it.
    The real source of the error is if the animation blueprint class is referenced somewhere in my character blueprint, be it on the mesh component itself, or in the blueprint (ie, I tried to fix it by setting the anim class to none on the mesh & setting the anim instance in the begin play, but the error was still present).

    I'm running out of solution, maybe I configured badly my animation blueprint, but I don't see how, any idea?

    Leave a comment:


  • replied
    The plugin is installed, I double-checked.

    But I found something, the error is located in ThirdPerson_AnimBP, which is the animation blueprint generated by the "Third Person" template (which I changed the parent class for "StateMachineABP"),
    However, if I create a new animation blueprint inheriting from StateMachineABP and put the node "Blend State Machines" in it, the error does not appear and my node stay there.

    Anyway, thank for the quick feedback, this was a strange behaviour but at least it can be easily fixed

    Leave a comment:


  • replied
    Originally posted by Emixam View Post
    Hello, I'm getting load errors about the node "FSM: Blend State Machines" in my animation blueprint when restarting my project.
    The error says "Can't find file for asset" and it removes the node from my animation blueprint, which breaks it.
    That error means you have a "FSM Blend" node in ThirdPerson_AnimBP... but the plugin apparently isn't installed ?!
    "Failed to load /Script/xxx..." means you don't have that C++ class anywhere in your project.

    I wonder how you managed to do that (unless you simply don't have the plugin installed at all);
    I've been using that node on all my AnimBlueprints for years now and I've never seen that error:

    Leave a comment:


  • replied
    Hello, I'm getting load errors about the node "FSM: Blend State Machines" in my animation blueprint when restarting my project.
    The error says "Can't find file for asset" and it removes the node from my animation blueprint, which breaks it.

    Click image for larger version

Name:	UE4Editor_20181227_174540.png
Views:	1
Size:	20.9 KB
ID:	1566043

    Leave a comment:


  • replied
    The function generator button only work when you create a Blueprint asset for your FSM Component.

    Then you attach to your Actor an instance of that FSM asset, instead of attaching a "raw" FSM Component to it.

    Leave a comment:


  • replied
    I've just tried both the 4.18 and 4.19 version of the plugin and the +Functions button no longer works.

    Debugging, I see that this:

    const auto &BP = GetBuilderBlueprint(OBJ);

    On line 213 of IUFSM_Editor.cpp is returning null.

    I'd really like to use this plugin for my current project. Any chance of a quick patch?

    Leave a comment:

Working...
X