Hey guys,
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);
It took me a bit to figure how I wanted to connect things but I’ve got it working nicely now.
To noobs of the future: make sure you declare using FlowCanvas; and using NodeCanvas.Framework; at the top when you want to call a function and change a variable respectively.
Author
Posts
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic.
Login
Register
By registering on this website you agree to our Privacy Policy.