How do I set a value with a certain chance?

0 favourites
  • 2 posts
From the Asset Store
A whole set you need to create a gorgeous winter 2d game
  • I'd like to know how could I apply probabilities in c2. For example, i have 20% of getting the value 1 Or 50% of getting another value and so on. The reason of this is that i need to create something random but in the same time control this randomness. Also Will be usefull when i add critical strike chance to the character.

    Thanks.

    Edit: I thought about using the random expression and use numbers from 0 to 100. Like if random(0,100) <= 20 then i have a chance of 20% of doing something. Is this expression reliable to do such thing?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'd like to know how could I apply probabilities in c2. For example, i have 20% of getting the value 1 Or 50% of getting another value and so on. The reason of this is that i need to create something random but in the same time control this randomness. Also Will be usefull when i add critical strike chance to the character.

    Thanks.

    Edit: I thought about using the random expression and use numbers from 0 to 100. Like if random(0,100) <= 20 then i have a chance of 20% of doing something. Is this expression reliable to do such thing?

    That could work, but you could also do something like:

    Choose(1,1,2) where you'd have a 66.6% chance of 1 and 33.3% chance of 2

    Choose(1,1,2,2,2) where you'd have 40% chance of 1 and 60% chance of 2

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