Random item from array node returns wrong data

Hello everyone.
I’m trying to get random unique integer from array several times. For that i decided to Remove by indexfrom array an item with integer that was already used. So that looks like this:


My Detail to spawn Array looks like this:
image
So whats wrong? Random node returns index and item data. And this data… doesnt matches.
To explain better here is a siries of screenshots of how this code works:
image
Here we can see that item with index 3 was removed from array and this item was “3”.
BUT we got “2” from Random node with supposedly index 3.
And this "index’’ is absolytely random. It doesn’t depend any way from Item we getting from same node. To proof that i paste several else examples of this code’s work. First (lowest) purple number is ITEM, second is Index, other green numbers are Array after removing index that was used .
image
image
image
image

Another surprising thing is that i discovered was that if i remade Random node with other nodes it will make absolutely same things.
image

Maybe someone have some thoughts on how to avoid this problem or you see whats am i doing wrong?

:exploding_head: :exploding_head: :exploding_head:

3 Likes

I also had some headaches with that random array item node lol.

do this instead:

the problem is that each time you read the node it returns a different value…just store the random number into a variable to make it a satic value :slight_smile:

4 Likes

You have SHUFFLE ARRAY :slight_smile:

image

3 Likes

Daamn i thought about that you wrote under first screenshot but did not get the most important of this thought
Now it works :partying_face:


Thank you very much for pointing me in the right direction :slight_smile:

3 Likes