Search Unity

What is wrong in this graph?

Discussion in 'Visual Scripting' started by Ts1nd, Feb 14, 2021.

  1. Ts1nd

    Ts1nd

    Joined:
    Jan 24, 2021
    Posts:
    108
    upload_2021-2-14_17-28-17.png
    I am getting this error at the bottom. Its rather simple function with string input and float output.Whats wrong?
     
  2. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,063
    Technically, nothing's wrong. It's a Bolt quirk. When logic outside the superunit wants to access your Value output, Bolt can't get it because (at least by my guess) it tries to retroactively execute the logic that produces that value but it's too complex for it to handle retroactively hence the "value cannot be fetched dynamically, it must be assigned" error.

    The solution to this issue is always the same - assign the value ie cache the value inside of a variable (a graph variable inside this superunit might work - use Select on Flow output and Set a graph variable with it and then Get that same variable for the superunit's Value output. I don't recall if graph var was enough or you have to use object scope variables, but graph var should work in theory. There's also the "cache" node that you can experiment with.

    If you're interested in learning more about how Bolt works under the hood, this is a good video to watch:
     
  3. Ts1nd

    Ts1nd

    Joined:
    Jan 24, 2021
    Posts:
    108
    Thanks for your reply. I already tried using graph and flow variables but got same error. It's sad that even simple things like creating function with 1 output is basically out of scope in Bolt. I encounter numerous problems like this and spend hours looking for solutions, that's ridiculous! I wish there was a way to convert my entire bolt code so far into C# so I would continue from there...
     
  4. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,063
    Note that you must implicitly use the Get Variable unit rather than the output of the Set Variable for the final superunit output value. I think if you use the output of Set Variable directly, it still tries to retroactively Set the value. Get Variable should work (in theory).
     
  5. Ts1nd

    Ts1nd

    Joined:
    Jan 24, 2021
    Posts:
    108
    I tried Get and it still didn't work. I ended up leaving 2 outputs values 1 from top and the other bottom calc and then when using this function I need to connect it to the right output which basically defeats the purpose of this function which was to create the "get variable" without having to use the get dictionary each time and also use the right dictionary based on input so in my example either "stats" or "combat". I have similar function with set variable and it works fine but that's because it doesn't have any output unlike this one.