How do I pick random value from array without repeating

  • I'm attempting to fill a column of 4 squares with color. Once all 4 are filled, I move on to the next column.

    I'm picking random values from an array by using

    array.at(round(random(0,3)))[/code:31vn5vtc] to pick which square to fill but the problem is it will repeat values and I don't want it to do that. I want it to only pick 4 times and then move on.
    
    Should I delete them as I pick them?
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I'm attempting to fill a column of 4 squares with color. Once all 4 are filled, I move on to the next column.

    I'm picking random values from an array by using

    array.at(round(random(0,3)))[/code:2zpwsj43] to pick which square to fill but the problem is it will repeat values and I don't want it to do that. I want it to only pick 4 times and then move on.
    
    Should I delete them as I pick them?
    

    That's what I would do: if I wanted to keep the array of random numbers, I'd copy the array first, and then pick-and-pop the array as I go along.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)