Can you get a random value from an array without replacement?

If you use the “Random” node in an audio cue, there’s a bool for “Randomize without replacement” which means that you’ll get a random selection but once one of the wav files is chosen, it’s removed from the list of available wavs until all wavs have been played.

I’m wondering if anyone knows how you would go about recreating this with the “Random Value in Range” node that you can use with an array? I’ve got an array of 16 items and I want to be sure that once a number has been selected, it won’t be selected again until the list has been exhausted but I have no idea how to do this.

Here’s my setup:

Would I create an array of integers and then somehow remove them from the array every time one is picked and then add them back in after the list is empty? Not exactly sure how to do that but I think theoretically it would work.

Hey, you can just use shuffle on an array with 16 numbers and then you access them one after another! <3

Shuffle? Never heard of it but thanks, I’ll try it the next time I load the editor.

Ok so shuffle is just a fast way of randomizing the elements of an array but it’s not without replacement. I specifically want the chosen wav file to be removed from the array after it’s been used and then placed back into the array once it’s empty. I suppose I could use two arrays for this and simply remove each element after I get it and then put that into a second array for the next use. I was really hoping there’d be an easier way to do this.

Super late respond, but why do you need to remove the element? If you used shuffle and pick the first element, you basically have a random element. Now if you pick the next one, the second element, it’s also random.