How do I make a chance of me to win a item based on the %?

0 favourites
  • 4 posts
From the Asset Store
Check preview, download and add value to your games.
  • So, im making a little game that when you press a button you get some items, but i want to make the player have a chance to get the items, like, 1% chance to get a diamond with the first item and 87% chance to get stone with the first item, is there a way i can do that? like a spawnrate, please help!

  • You can set a local variable to round(random(1,100)) and then have conditions, if variable = 1, spawn object A, else spawn object B. Or if it was 10%, if variable is between 1 and 10 then spawn object A etc

  • You can set a local variable to round(random(1,100)) and then have conditions, if variable = 1, spawn object A, else spawn object B. Or if it was 10%, if variable is between 1 and 10 then spawn object A etc

    so, i just did that, when the button is pressed, set woodchance to random(1,100) set dirtchance to random(1,100) set gravelchance to random(1,100), etc etc, and if woodchance = to < or = to 5 (the chance) give 1 wood, but it gives a random number to everyone like this time it gave evertig 41 and wood 315, how do i fix that (theres no question mark because when i press alt and w two warning appears)

    update: i just checked and if you dont click the button you keep getting one of everything non stop

    update 2: fixed, it was a silly error, thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • ok! glad it's working :)

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