x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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:

alt text

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.

Product Version: UE 4.15
Tags:
more ▼

asked Jul 03 '17 at 01:43 AM in Blueprint Scripting

avatar image

TorQueMoD
1k 75 98 137

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

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

more ▼

answered Jul 03 '17 at 03:02 AM

avatar image

Ninjin
3.9k 87 35 149

avatar image TorQueMoD Jul 07 '17 at 06:28 AM

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

avatar image TorQueMoD Jul 11 '17 at 11:38 PM

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.

avatar image Ninjin Aug 11 '17 at 09:33 PM

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.

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question