Search Unity

Question Why do these Two Single (Slightly) Different Results Have Different Outcomes?

Discussion in 'Visual Scripting' started by Ecliptec_Mobile, Nov 16, 2022.

  1. Ecliptec_Mobile

    Ecliptec_Mobile

    Joined:
    Dec 17, 2017
    Posts:
    33
    I have created a simple graph which, on Start, flows to create an item in a list. The futher flow attempts to find an item in the list, and remove it. Final part of the flow is to Evaluate that the list is empty (item has been removed). This outcome is as expected.

    However, slightly different graph, flow ends after constructing the list. The item removal attempt in this graph is triggered by a key press. Again, finally followed by an Evaluation check. This time, the graph is _not_ empty.

    One thing I do note, is that the initial list is created on Start (as expected) verified by breakpoint. However, after hitting the key press, I note that (again with a break point) a new item and list are constructed, firstly on item removal method (HnadleNpcKilled) and again constructed on Evaluate. Both of these methods are defined in the same class as my list.

    Screenshot 2022-11-16 190340.png Screenshot 2022-11-16 190408.png
     
  2. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,079
    UVS does not cache values for you automatically. It doesn't matter that something was done in Start in the second example, the Space press will retroactively trigger most, if not the whole, of the logic due to value connections. Doesn't matter if Flow is directly connected or not. You can use Cache node to work around that or simply use UVS variables to cache the value produced in Start and then reuse it for the second Space action.