FSM Super Action State OnUpdateActions

NodeCanvas Forums Support FSM Super Action State OnUpdateActions

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #11162
    feelx
    Participant

    Hi,
    a question about the OnUpdateActions of the Super Action State: I thought (as the name suggests) the actions in the OnUpdate list would be called every frame/every “update”, but apparently that’s not the case? How would I go about implementing my own OnUpdate function for that specific state then (instead of implementing the OnUpdate function and checking in what state I am manually).
    Cheers,
    Felix

    #11168
    Gavalakis
    Keymaster

    Hello,

    The action in the OnUpdate list do get called every frame, but only as long as the state is active. As explained in the help text of the node in the inspector, The Super Action State is Finished when all actions in the OnEnter list is finished. This is done so that the state is able to Finish at some point and as such OnFinish transitions take place.

    If you don’t really want this to happen, a way around this would be to simply add a Utility/RunForever action in the OnEnter list of the state.
    In the next update I will probably add a option to turn on/off this behaviour.

    Please let me know if this works for you.
    Can you also please clarify your second question about implementing your own OnUpdate and what you mean by that? 🙂

    Thanks!

    Join us on Discord: https://discord.gg/97q2Rjh

    #11232
    feelx
    Participant

    Hi,

    ok I thought the Super Action State is finished when a transition prerequisite becomes true and the FSM transitions to another state? The current behaviour doesn’t make much sense to me, sorry. Please make this behaviour optional so that the OnUpdate actions get called as long as the FSM is in that state.

    Concerning the second question – basically I mean this: https://nodecanvas.paradoxnotion.com/section/fsm-callbacks/ … so if I wanted to do sth while the Super Action State is running, I could implement OnstateUpdate in one of my components on the gameObject. But then I would have to check manually for what state I am in, using a string. That’s kind of ugly in my opinion.

    How would you go about doing sth specific to a certain super action state in your component while the state is running?

    #11240
    Gavalakis
    Keymaster

    Hey,

    I kind of agree with you here 🙂 I will change the Super Action State behaviour to what you suggest (or at least add an option for that).

    Regarding your 2nd question, do you have anything to suggest, as I can’t think of a better way to handle this?

    As for your last question, can you please clarify what you mean? Do you mean something different than implementing the OnStateUpdate callback?

    Let me know.
    Thanks.

    Join us on Discord: https://discord.gg/97q2Rjh

    #11251
    feelx
    Participant

    As for your last question, can you please clarify what you mean? Do you mean something different than implementing the OnStateUpdate callback?

    Hi,

    well I guess at the moment that’s the way to do it then (the OnstateUpdate callback). Mecanim has StateMachineBehaviours with the according callbacks so you can write your code specifically for a certain state and that state only. No checks for what state you’re in.
    Maybe that would be a way to go? To have your own Classes/MonoBehaviours for each state, if you wanted to. That would mean more files, but way more clarity.

    And again, please implement integer Hashes for the state names 🙂

    Cheers,
    Felix

    #11254
    Gavalakis
    Keymaster

    Hey,

    Now I see what you mean.

    The best way to model an FSM state, would be to write custom Action Tasks and then use/assign them in an Action State, pretty similar to what you would have done for Mecanim, only in this case our StateMachineBehaviour scripts, are the ActionTask scripts.

    Action Tasks get callbacks when the state they are assigned in Enter/Update and Exit. Here is the callbacks called in an Action Task for each case:

    -> OnExecute
    -> OnUpdate
    -> OnStop

    Is that what you mean? 🙂
    Let me know.

    Join us on Discord: https://discord.gg/97q2Rjh

    #11264
    feelx
    Participant

    Hi,

    ah yes, of course. Seems pretty obvious now that you mention it 😛
    Thanks a lot!

    -Felix

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.