Is it possible to listen (given a callback or some other way) to a ScriptMachine starting the execution of a FlowGraph and reaching the end of any flow, without having to manually insert some sort of event dispatching node at the start and end?
Basically just want to bookend the start and end of any given FlowGraph sequence when started in a specific context.
could you reword this?
You don’t mean the On Enter and On Exit flow?
are you asking how to enter a transition?
No problem!
I basically just want to be notified when a ScriptGraph begins execution and when it has finished executing.
For example, if a ScriptGraph is to serve as a cutscene, I want letterbox bars to automatically enter when the ScriptGraph starts, and automatically dismiss when the ScriptGraph finishes.
I can do this easily if there’s some sort of “OnEnter” or “OnExit” event that I can listen to - or even if I’m somehow able to poll for whether or not the graph is running so that I can dispatch my own events.
Without this notification, I have to basically create a “DispatchCutsceneStart” and “DispatchCutsceneEnd” Unit, and ensure that they are manually placed at the start and end of all relevant FlowGraphs.
Ah, the state machine graph should open up with 3 nodes.
On Enter State
On Update State
On Exit State
On enter and On exit do what you ask out of the box.
Just have to trigger the state machine to transition, this exits the state.
In this example I am self transitioning. (right click node and select make transition)
inside the transition node, I’ll place a custom event just to trigger it
So basically, When the state starts, prints just started bruh to the console,
and when space is pressed the state exits and prints “Hey Yo I’m Done” than re-enters
Otherwise, if you just want to be notified in a regular graph, you can also use the custom trigger to send the advisement.
Do you need to print the result for your eyes to debug or are you looking to send a value?
if looking to send a value it may be easier to use the state machine.
hope this helps
Thanks! I think the crux of my issue is that I want an external C# script to be able to automatically respond to the starting and ending of a ScriptGraph, regardless of what nodes are actually inside. Essentially just the ability to put OnScriptMachineStartRunning() {} and OnScriptMachineStopRunning() {} somewhere.
Unfortunately it looks like, as you said, I’ll have to add a custom trigger to the start and end of my graphs explicitly and EventBus.Register them to external callbacks. Not the worst thing in the world, but surprising that there isn’t a simple way to ask a ScriptMachine if it’s doing anything at the moment.
1 Like