I’ve set up an graph in which I create a new game object. Now I want this game object to have a predefined flow graph. I’ve added a flow machine to the object with the “add component”-element and it works, but I can’t find an element like “flow machine set graph” or “flow machine set flow macro”. Do I have to make changes to the unit options? Or how can I attach a predefined flow macro to the flow machine of the object?
At the moment Bolt have nothing to change the flow graph asset in a flow machine. We have a task to fix this.
Until we get nodes integrated in a new release, you can add this script in your project.
For Bolt 1.4.13(from the asset store)
Create a new c# script in your project named: TempFlowMachineNodes
Copy and past the code below and save the script.
using Bolt;
using Ludiq;
using UnityEngine;
[IncludeInSettings(true)]
public static class TempFlowMachineNodes
{
public static void AddFlowMachineComponent(GameObject gameObject, FlowMacro flowMacro)
{
gameObject.AddComponent<FlowMachine>().nest.SwitchToMacro(flowMacro);
}
public static void SetFlowGraph(object goOrFlowMachine, FlowMacro flowGraph)
{
if (goOrFlowMachine is GameObject go)
{
go.GetComponent<FlowMachine>().nest.SwitchToMacro(flowGraph);
}
else if (goOrFlowMachine is FlowMachine flo)
{
flo.nest.SwitchToMacro(flowGraph);
}
}
}
Click on Tools → Bolt → Build Unit Options
Now in your graph you will be able to find the SetFlowGraph node to swap your graph asset. You can link a game object or a flow machine component to it. The Game Object will only interact on the first flow machine component.