I’m using the Unity Timeline/playables to control my game state over time. It’s a bit of a work around at the moment but I can trigger functions and change variables in C# scripts at runtime with this method.
Is there a way to access custom flowcanvas functions and blackboard variables from external C# scripts? I’d like to use flowcanvas for more behaviors but I have to be able to trigger them through the timeline editor via C#.
Sorry for the noobish question; I couldn’t find a good scripting reference on the topic.
Yes, it’s possible to call FlowCanvas Custom Functions as well as access (get/set) Blackboard variables in code.
To call a Custom Function:
– Get a reference to the FlowScriptController component attached on your gameobject and call the “CallFunction” method, like for example: GetComponent<FlowScriptController>().CallFunction("MyFunction");.
Please note, that you can also pass parameters, if your Custom Function does take parameters, but there parameters need to be passed in correct order, like for example: GetComponent<FlowScriptController>().CallFunction("MyFunction", 10.5f, true)
To access Blackboard and get/set their value:
– Get a reference to the Blackboard component attached on the gameobject and use either ‘GetValue’ or ‘SetValue’ methods, like for example: var number = GetComponent<Blackboard>().GetValue<float>("myFloat");
or: GetComponent<Blackboard>().SetValue("myFloat", 10.5f);