Udon Graph has unexpected behavior when a Branch is used in the Body of a For loop
L.E.G.O.S.
SDK ver: 3.10.2
There seems to be certain conditions where the False output of a Branch does not update the value for the index of the loop properly, causing the loop to pass the incorrect value into "Get" nodes for arrays. This issue occurs in both ClientSim and in-game.
I don't know if I fully narrowed it down, but I was assisting someone with Udon, and in the process encountered what appears to be a bug in the compiler. In my provided example, this graph should loop through an array of MeshRenderers, and then change the material depending on the value of the isToggled bool.
see video in action: https://www.youtube.com/watch?v=VanIgAJRwoI
The "True" side executes as expected, but when the Branch evaluates to "False", the loop executes the expected number of times, but it reuses the last value of the index instead of updating the index along with the loop. This makes is to the 4 cubes in the array change to red when isToggled is True, but when isToggled is false it sets the last cube in the array to blue 4 times in a row.
Possibly the issue could be with the "MeshRenderer[] Get" node, as if its input "int" is not getting updated properly during the loop.
As can also be seen in the video, for some odd reason, adding a "Debug Log" node with a "String Format" node that accesses the index prevents the unexpected execution from occurring. Curiously, it's specifically the "String Format" node that prevents the issue, as disconnecting it (but keeping the Debug Log) still has the issue occur.
Log In