Set graph of flow machine

Hello,

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?

Hope u can help me.

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
    6804545--789386--upload_2021-2-4_16-9-12.png
  • 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.
    6804545--789392--upload_2021-2-4_16-11-48.png
  • Example use case.*
1 Like

do you have a version for bolt 1.4.15 ?

1.4.13 and 1.4.15 have identical API so this solution should also work for the latest version of Bolt.