Search Unity

Other [Bolt] Is it better to use many Flow Macros or put all the code in one?

Discussion in 'Visual Scripting' started by Melanzue, Aug 2, 2021.

?

One or Multiple?

  1. One

    66.7%
  2. Multiple

    33.3%
  1. Melanzue

    Melanzue

    Joined:
    May 12, 2020
    Posts:
    8
    For example, should I put the logic for movement, needs and e.t.c of a character in one Flow Macro or divide everything into multiple?
     
  2. Carcophan

    Carcophan

    Joined:
    May 10, 2021
    Posts:
    79
    Are you asking specifically for your movement management? Or all elements?

    There are instances where I put all control in one macro tied to one object - but then when it gets too crazy, start splitting the reusable sections of code off into individual macros and call them as super units. So it is kind of the same thing as having it all in 'one large macro', but kind of with smaller macros inside of the main macro - just to help keep it clean and neat and readable.

    Just my newbie perspective.
     
  3. Melanzue

    Melanzue

    Joined:
    May 12, 2020
    Posts:
    8
    I have the same. One large macro with lots of super units. It's very easy and readable. But my main concern is the performance. People say that it's better to have lots of C# scripts then use 1 for eveything. So I thought this logic applies to Bolt, too.
     
  4. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,072
    Every layer you go deeper with superunits adds a bit of initialization cost. So don't go too nuts with superunits 30 layers deep. That said, the impact of embedding superunits into other graphs is pretty negligible in the grand scheme of things. It's a micro optimization. And multiple FlowGraph/ScriptGraph workflow on the same gameobject is not well supported right now. It works, but viewing the right graph when the object is selected or in Play mode often has to be done by manually pressing the Edit Graph button in the Inspector. A lot more clicking and buzzy work that way. So I do one graph per GameObject.
     
    Melanzue likes this.