Search Issue Tracker

By Design

Votes

0

Found in [Package]

1.4.10

Issue ID

UVSB-12

Regression

No

For Loop retrieves one list item lower on Exit flow when Break Loop unit is used.

Package: Visual Scripting

-

Escalated - 3 months ago. 

[Original issue link|https://support.ludiq.io/communities/5/topics/4664-for-loop-retrieves-one-list-item-lower-on-exit-flow-when-break-loop-unit-is-used]
----
So here's a simple operation. I want to find an item in a list and then do something with it on For Loop's exit flow. The problem is that if the Break Loop unit is used to achieve this, the exit flow receives one item lower than you'd expect. 

Like in this image - I break the loop on the "5. CORRECT" item but on exit flow it retrieves one item lower  - "6. WRONG".

!https://support.ludiq.io/s/attachments/21929/5/1072/873e8c18d019e46a76407ba1af214375.png!

 

I can, however, achieve the desired result by using the "Cache" unit. But as far as I know, this specific scenario is not documented anywhere and had to be discovered through trial and error. 

!https://support.ludiq.io/s/attachments/21929/5/1072/d9bf77f4ab71f195502f271c1eb9d48b.png!

Another point of interest is how For Loops retrieved item index differs when the Cache unit is in the graph. Without the Cache unit, the index value is "5" which again is one item lower than requested, but with Cache unit in the graph the index value is "4" which is correct. 
 
Bolt Version:
1.4.10
Unity Version:
2019.2, 2019.3
Platform(s):
PC
Scripting Backend:
Mono
.NET Version (API Compatibility Level):
.NET 4.x

  1. Resolution Note:

    This is not a bug, but a misunderstanding about the "ForLoop" mechanics.

    The port "Exit" does not return the index that would matches the break condition, but instead, the next one.

    The attached project (Unity 2020.1/Bolt 1.4.12) shows the proper way to assemble the graph.

    A screen shot for quick reference was also included.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.