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
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? 🙂
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?
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 🙂
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: