Remove Index in a Loop not removing from Index?

This is all in one blueprint. I’ve been at this for an hour, it is meant to go through all five instances of an object in the world and assign different kana (a,i,u,e,o) to each one. The textures all work but I keep getting repeats despite removing the index of the one used. Because I’ve never posted here, they don’t let me put more then one image. But everything else works except this remove index, which is in a loop through checking an array of objects that it’s assigning

Instead of modifying the array in-loop with remove index, try doing a Shuffle on the array (or a copy of it) before your loop and just iterating thru it normally.

When you remove an index inside a loop, especially if you’re looping forward, the array elements shift and that can cause repeats or skipped values. Even if everything else works, modifying the array during iteration can lead to unexpected behavior in Blueprints. A common solution is to loop backwards or remove the selected values from a copied array instead of the original one.

By the way, visit Surah Yasin to read the full Arabic text with proper vowel marks, listen to audio recitation, and explore tafseer to understand its meaning clearly.

the real issue is your Random node, you have 2 pins off it which means it will call twice and return 2 different results (yes counter intuitive i know)

so to explain your SetNode could be (ValueX, index1) and your RemoveIndex is (ValueY, index2)

creating a mismatch between what you return and what you removed.

the correct way is to cache the index, Get(index) to cache the value then remove the index

1 Like