How do I choose different values?

0 favourites
  • 2 posts
From the Asset Store
Adjusting the game screen for different resolutions (Letterbox scale)
  • Hi

    I am working on an Affix system of items for the game. I have a problem with reselecting the same affix.

    For example:

    When an item is created (after killing an enemy) a roll is enabled, for example random(1,10) for Affix_1 and Affix_2.

    Now how do I prevent the roll for Affix_2 from being different from the one for Affix_1, for example, if Affix_1 drew the number 2, I would want Affix_2 to have every number in the random(1,10) range except the number 2.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hello,

    Put the values inside an array, then choose a random value from that array like :

    randomIndex = round(random(0, Array.With-1))

    value = Array.At(randomIndex)

    Then delete this array entry like :

    Array.Delete(randomIndex)

    This way, the randomly chosen value is removed from the array and your can iterate once more for a second roll (with another random index).

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