Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

3 different values from 1 input? Bug

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

  1. Ts1nd

    Ts1nd

    Joined:
    Jan 24, 2021
    Posts:
    108
    Why there are 3 different values from the "Damage" source? Whats going on?
     

    Attached Files:

    • bolt.png
      bolt.png
      File size:
      129.8 KB
      Views:
      305
  2. Ts1nd

    Ts1nd

    Joined:
    Jan 24, 2021
    Posts:
    108
    here is how it looks outside:
    upload_2021-2-21_11-14-56.png

    everything is on the "Enter State" coroutine so no update etc. Should be calculated once
     
  3. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,049
    Bolt caches connection values and only refreshes them when the logic is triggered again. If part of your logic was not triggered, then it'd display the old value while the other parts that were triggered and executed would show the new values.

    Alternatively, Bolt can also retroactively execute logic when a value is requested. So Bolt might be executing your previous superunit multiple times to get the Damage value. You should either cache that value inside a variable or use "cache" node between superunits.
     
    Haneferd likes this.
  4. Ts1nd

    Ts1nd

    Joined:
    Jan 24, 2021
    Posts:
    108
    Apparently the reason was some very unintuitive way Bolt handles random values - when you get random value and access it from multiple sources, it will recalculates it each time instead of using the already calculated one. I am wondering if the same will happen with superunit functions, will it calculate superunit output each time its accessed even if its deterministic and the same all the time?

    I fixed it by setting object variable "Roll" for each character and thats ridiculous. Should be calculated in code...
     
  5. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,049
    In C# you typically still cache the results of a function in a variable (even if a local variable). Bolt allows you to pass values without defining local variables, but it doesn't automatically cache them for you. In that way it's more flexible than C# but I agree - it can be unintuitive.