For each loop on array run infinite

I have a problem of debuging.

First picture is my blueprint.

Skill Range is member of superclass, and have only one default variable.

When i build project, for each loop run infinite.

Like pic 2 and pic 3.

I try to fix this one, but cannot solve it.

What is wrong? What makes loop run infinite even i don’t add anything to array until loop?

The first 2 loops will keep adding indexes to the IncreasingVector array. As soon as the entry is added, the array grows and it will have to do one more iteration the inner loop, which results in adding additional indexes and additional iterations.

Each time you iterate through IncreasingVector, it gets bigger, it never finishes.

I was looking to it, and my first question is, why use AddUnique?

I mean, since you increment the value on the element it will always add a new element to SkillRange unless the value was added before. For instance, if you add an element (0,1,0) and it got to the index 0, on the next time will try to sum it, for instance (1,0,0), the result element will be (1,1,0). So when you go again on add unique, the array will be [(0,1,0),(1,1,0)]. And if you later on, you try to add (-1,0,0), beside the result element will be (0,1,0), your array will continue [(0,1,0),(1,1,0].

Anyway, I don’t get the point on AddUnique.

But for the infinite loop, can you show me where you are calling the function Increase_Skill_Range?

I agree with AddUnique - it makes little sense in this instance. Even if SkillRange has 1 element only, it’s enough to get stuck in the loopy loop.

I call that function in Initialize function.
You can see it left side of first pic

Isn’t this the most classic example of infinite loop:

You’re doing the same but with extra steps…

ah… It’s such a terrible news…

Now i need to fix Simmilar bugs. I guess more than 20 blueprints. thanks for help.

No problem. Good luck!