A FlowCanvas FlowScript can be used as a FSM State to model the state completely with visual scripting! After you have downloaded the FlowCanvas bridge extension, it will be possible to add such a FlowScript State through the context menu and found under the “Nested” category.
The FlowScript State node inspector has only two settings (apart from the FlowScript reference of course). Success and Failure Events.
Since FlowScripts can Finish in Success or Failure, an event can optionally be send to the FSM when this happens. These events are meant to be used by a CheckEvent condition added on the FlowScript State’s transitions like shown in the example FSM image above.
Using these events is completely optional. If you opt not to use them the FlowScript State will simply call the first ‘OnFinish’ transition as soon as the FlowScript is Finished.
Within the FlowScript, the OnEnable, OnDisable and OnUpdate events can be used to model the state’s OnEnter, OnExit and OnUpdate functionality respectively.
The FlowScript Finish node can be used to Finish the state. As explained earlier, when the Finish node is called and considering you have set event names to be used in the FlowScript State node inspector, either the Success or Failure event will be send to the FlowScript State’s transitions. If no event names are set, the first OnFinish transition will simply take place.
Last but not least, all Variables used in the FSM, are propagated down the nested FlowScript like all other nested Graphs work.