Announcement

Collapse
No announcement yet.

UFSM: Finite State Machine

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

    Quick question: is there some way to set up an interping transition value and a rule or a timer when it moves from one state to another, or should the transition be a state itself? This would be useful for feeding into animation blueprints and things like that.

    One thing I thought about doing was to add "transition" state and have separate "old state" and "new state" values, then specific events to call for their transition rates.

    So for example if I was doing AI and I had a character charging it could go: "charging -> transition -> stop", where the transition from charge to stop would feed a bunch of things like deceleration and animation blend weights. Then inside the logic for the transition I could take into account if there was anything in front of the character or not and stop faster or slower as needed. The only requirement is that it needs to tick and interp away some values while being able to do custom environmental queries.

    So I guess I'm asking does any facility for this exist already or is there a particular way you'd set it up? I have a rough layout but I'm sure you have a better understanding of it than me.
    Last edited by Antidamage; 03-14-2018, 06:32 AM.

    Comment


      Originally posted by Antidamage View Post
      Quick question: is there some way to set up an interping transition value and a rule or a timer when it moves from one state to another, or should the transition be a state itself? This would be useful for feeding into animation blueprints and things like that.
      The thing you think of doing might work pretty well; Internally, in the Animation Graphs, "transitions" are states too. They are just "presented" differently to the Blueprint user.
      Btw, did you try to use one of the "Set State Async" nodes for this ?!

      Currently none of them return the actual value of seconds they are waiting, but those only change State after its Timeline has completed evaluating its "Wait For Seconds" input.
      I could expose that timeline to the Animation Graph as well, right now the float is private to the Async node alone.

      Edit: "Async" nodes can be seen in this screenshot:

      Last edited by BrUnO XaVIeR; 03-14-2018, 07:20 AM.
      | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

      Comment


        Update with support for Unreal Engine 4.19 have been submitted for review.
        | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

        Comment


          Hi Bruno, Thanks for making this, once working, it should solve some implementation problems I was having for a game I'm making.

          I'm using 4.19 built from source from git.

          My generate function's button doesn't seem to do anything.
          Enabling Debug on the FSM component shows me a bunch of warnings about the functions not being found.


          Also, My enumerator just seems to be detached/different than the enumerator being output by the anim bp.



          When playing with debug on, the state that is being output is different than the state defined in my enumerator. I've read the wiki article multiple times and can't seen to find much info on if we are just meant to make our own enumerator in blueprint, define it in c++, or if it gets generated from our anim bp or something like that?
          Last edited by wasti; 04-09-2018, 02:39 PM.

          Comment


            If the button to generate functions doesn't work on 4.19 that means you're not using latest plugin version downloaded from Launcher.
            4.19 only works with latest plugin release, EpicGames changed too many things on 4.19 and older code won't work if you simply recompiled DLLs instead of downloading new plugin source.
            | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

            Comment


              As far as generating the functions, I can get away without. My main concern/issue at the moment is the enumeration difference between what is output by the anim bp's state machine, and what my enumerator is.


              I downloaded the 4.19 launcher version and then installed to engine via the launcher for 4.19 and then copied the plugin directory from the 4.19 engine/plugins/marketplace to my source built dir.


              I did just attempt to recopy the 4.19 launcher plugin to my source built directory and it did want to recompile again.
              Last edited by wasti; 04-09-2018, 02:39 PM.

              Comment


                Originally posted by wasti View Post
                I downloaded the 4.19 launcher version and then installed to engine via the launcher for 4.19 and then copied the plugin directory from the 4.19 engine/plugins/marketplace to my source built dir.
                {"data-align":"none","data-size":"thumb","data-attachmentid":1457929}
                Hmm... I see in your screenshots that you have attached a "raw" FSM Component to your BP_Pawn asset.

                "+Functions" ( function generator ) only works when you create a Blueprint asset for your FSM Component... (right click Asset Browser --> Synaptech menu --> New FSM Component).
                And then within the new FSM Blueprint created you can generate functions.
                ​​​​​
                If you try to generate functions from your class instead of a Blueprint of type FSM, Unreal ignores you because it knows the Code Reflection system won't work in that case.

                If you don't want to create a FSM Component Blueprint then you have to create all your functions by hand... It's the way Code Reflection works.

                TLDR:
                Attached "raw" FSM Components and FSM Blueprints are different things.
                You can create a FSM Blueprint and still attach it like a normal "raw" Component, so is always better to create a FSM Blueprint asset unless you don't use "Auto-Flow" or go full C++.
                | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

                Comment


                  Awesome, I didn't see that in the wiki article. I'll try it and let you know. Thanks

                  Thank you for the fast replies.


                  Well that seems to have cleared up not being able to generate functions. However my enumeration still seems really messed up. Here is a screenshot showing the enum should be on the state "AcceptInitialBets" but in game, the FSM debug is reporting the state to be "Attract_DealCards".
                  Click image for larger version

Name:	fsm_enum_issue.jpg
Views:	7
Size:	58.4 KB
ID:	1457944
                  Attached Files
                  Last edited by wasti; 04-09-2018, 02:35 PM.

                  Comment


                    Originally posted by wasti View Post
                    Awesome, I didn't see that in the wiki article. I'll try it and let you know. Thanks
                    This is my fault btw...
                    I have to learn how to create better documentation. Things seems obvious to me then I don't remember to mention them when writing how-to guides.
                    | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

                    Comment


                      It's no problem; I'm used to dealing with a lack of documentation. Definitely helps that you respond so quickly


                      I guess the root of my issues is this node Click image for larger version

Name:	fsm_states_enum.jpg
Views:	6
Size:	14.7 KB
ID:	1457952

                      Like I was saying, it seems that the state enum being output by any of the fsm component events (onUpdateState, ect) is different than the enumerator that I have created and named Enum_States.
                      Attached Files

                      Comment


                        Are you using "Set State..." nodes anywhere?

                        When using FSM Animation BP (which is optional btw), on the Pawn/etc you should never use Set State nodes then.
                        The Anim BP will always try to control by itself the State your FSM Component is at, so you have to make sure the Target FSM name in your Anim BP is exactly the name of your FSM Component attached to Pawn.
                        States out of sync in that case seems to be due to the Anim BP not able to find the FSM Component at all.
                        ​​​​​​
                        Also, reparenting your Anim BP isn't a requirement anymore. There are new animation nodes (red events) that can be used in any AnimBP Graph now.
                        | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

                        Comment


                          hmmm, no set state nodes anywhere. I'm currently moving my code from being all in the game mode (and being dependent on that enum) to their respective functions in my newly created bp_fsm_component.

                          I would be willing to share more of my project/issues in a more private context as this project/game is going to be released, ect ect. (if you want to know more of the issues I've faced/want some feedback on what could be added to the wiki article to help future users out)

                          Comment


                            The "red event" node I was referring to is a new node you can use from any Animation Blueprint Class.
                            Did you try to use this one?
                            It's what we use on our projects instead of re-parenting AnimBPs (to sync FSM States to Animation States):

                            | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

                            Comment


                              is that needed if I am using OverrideFSM True?
                              Click image for larger version  Name:	fsm_overridefsm.jpg Views:	2 Size:	17.4 KB ID:	1458002

                              I tried using set state and it doesn't seem to change anything. I refer back to one of the images I posted previously, this is still happening, Click image for larger version

Name:	fsm_enum_issue.jpg
Views:	8
Size:	58.4 KB
ID:	1458010
                              basically, the anim graph is correct and the state should be on acceptinitialbets, however, the debug (and a printstring attached to the update function for attract_dealcards) confirm that the state machine is running and talking to blueprint correctly, but the state that is being output as the active state is somehow different/detatched from my enumerator. (and now also from the state which the anim bp is in)
                              Attached Files
                              Last edited by wasti; 04-09-2018, 03:38 PM.

                              Comment


                                Originally posted by wasti View Post
                                is that needed if I am using OverrideFSM True?
                                No, that is an alternative system.
                                If there's a bug hidden in the system you are currently using, maybe this alternate system works the correct way on your project.
                                | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

                                Comment

                                Working...
                                X