getting random values from an array

  • I want to get three random values from a one dimension array, without any repeating value. It's easy to get one random value by creating a random number but how do I create second and third random numbers without te risk of getting the same value before?

    In fact what I'm trying to do is creating an npc dialogue system in which there are 10 chat topics but the game randomly selects three of these. So the player will select a chat subject among these three. Can you think of a different and better approach to carry out this in Construct 2?

  • You could make it a 2D-array and if you get a value at X2 then you set X2Y1 to "picked" or something. Or you create another array where you save the already picked values or you create 3 additional variables and save the value u get in var1, the second in var2 and so on and everytime u get a value randomized u check the variables if that value is already picked.

    So many ways..

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)