Search Unity

Question Variables Not Set as Expected / Shows Different Values In Flow

Discussion in 'Visual Scripting' started by Carcophan, Dec 14, 2021.

  1. Carcophan

    Carcophan

    Joined:
    May 10, 2021
    Posts:
    79
    Hello everyone.


    I am simply trying to add one to a 'Count of Used' variable, via a Get Variable call and Add.

    I had to output this Get+1 value into a string for testing and saw it wasn't right. This new value is also set back to the variable, and output again - but this time it is correct.


    upload_2021-12-13_19-54-58.png

    This is the output from the first iteration. The button was pressed once, so both values should be 'one'. Set Var correctly displays, but Count of Used seems to inflate the output value by one extra each use.
    upload_2021-12-13_19-55-15.png


    So before the 'set variable', the number is wrong - but after it is set, it is correct.

    What am I doing wrong here?


    Thanks all.
     
  2. Carcophan

    Carcophan

    Joined:
    May 10, 2021
    Posts:
    79
    A similar issue, probably the same thing really, is when I try to assign a value to a variable like this.

    You see the (-100,0,-100) on the teal flow path, but the variable window on the left, shows the old / last know position. (This is also reflected visually on the map, obviously)

    upload_2021-12-19_18-56-30.png

    PathCheck values should equal CollisionCheck values at this point.

    What am I doing from from an assignment standpoint?
     
  3. Carcophan

    Carcophan

    Joined:
    May 10, 2021
    Posts:
    79
    Changed the title of the thread, to try to better reflect the concern.
     
  4. JonathanCzeck

    JonathanCzeck

    Joined:
    Mar 21, 2013
    Posts:
    12
    I don't have any answers for you, but being that nobody else has responded it may be helpful to know that I'm having similar consistency issues. Values in the graph seem to get stuck on values randomly, and don't always match what is displayed in the graph variables section. The visual scripting seems way too buggy to use right now, and it seems so pervasive that I don't see a point of filing a bug. The team can just dogfood it and find them.
     
  5. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,075
    I can't really explain the OP image issue, but values shown on connections in graphs are cached and not refreshed every frame. It only refreshes when that connection gets polled again. If that specific connection has not triggered, it'll show the value it had when it last got triggered.

    So that cached value might be outdated, especially when some other node/graph has changed the value that connection sources from.
     
  6. Carcophan

    Carcophan

    Joined:
    May 10, 2021
    Posts:
    79
    This is a great suggestion, but it doesn't seem like a visual / display issue on the flow graph. The game objects on screen are not moving to the position it should, which is what the flow graph is setting.

    To clarify a little - this is sort of like a path-finding thing. Where I am trying to move the PathCheck to the location of the CollisionCheck. Go along this path until it collides, set that location as the current location.

    In this example, say that the collision happened at -100,-100. You can see the flow graph sending -100,-100 to the Set Variable node for PathChcek. However, the variable on the left pane still shows the old position, and the on screen object stays at that same old position. It doesn't make the actual move to -100,-100.

    I should also add, that debugging strings and additional unrelated actions that occur AFTER this node/sample image, they still fire as expected, etc. Which is confusing to me, as in, how can they flow and trigger properly, but this isn't assigning correctly.


    By your suggestion, are you saying I should take some kind of additional step to allow for a 'refresh' here? And why are similar actions throughout the graph NOT experiencing the same issue - I feel like if it was a problem with Unity overall, it would impact my scenario more than it is now. Which gives me hope that it is actually 'my fault', because I am misconfiguring or misunderstanding how things actually work.
     
  7. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,075
    I only explained why some visually displayed values on connections in graphs might be outdated. ie the values displayed on connections refresh only when that connection is triggered. If the connection does not trigger but the value is changed elsewhere, that connection will still display the value it polled last time even if it's not up to date with the actual variable.

    But it can only be visually outdated in the graph on the connection. It should not impact functionality in any shape or form, nor should it have any impact on Unity VS variables. There's no other way of forcing the displayed value refresh besides triggering the connection again. It's also likely not an issue with Unity itself but it can definitely be an issue with Unity Visual Scripting which is still very new. If you can reliably reproduce this issue with a minimal test case, I'd report it as a bug to Unity via regular bug reporting means.