Random choice between two numbers

0 favourites
• 10 posts
From the Asset Store
Be quick and choose the right answer for the shown equation.
• I need to get a random number that is -20 OR 500, not a range, I need it every tick.

I already tried with the | operator but I don't think it works this way <img src="smileys/smiley1.gif" border="0" align="middle" />

Thanks

• There is an OR plug in you could look into. :)

Or perhaps you could force the range to result in 500 with a little math.

I could also see a variable driven solution,

random, if result > than X, variable = -20

random, if result < than X, variable = 500

• I need to get a random number that is -20 OR 500, not a range

Thanks-20+floor(random(0,2))*500

• > I need to get a random number that is -20 OR 500, not a range

> Thanks-20+floor(random(2))*500

• I see that the tough laws of mathematics always rule over our world, never though about doing it like this!

Wouldn't your example yield -20 or 480 though?

• It would :) I believe you now know what to do to make it work for you though. Cheers

• If someone who doesn't know how this works.

-20+floor(random(2))*520 (this is the right formula in my case)

a general would be

You need number X or number Y

X+floor(random(2))*(Y-X)

p.s. Thank you very much ranma

• i just noticed the system expression:

choose(Value, Value)

choose(-20,500)

have fun!

• Good to now! Thanks Again!

• Try Construct 3

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

Construct 3 users don't see these ads
• Yeah, I just noticed this thread and was going to mention choose(). Incredibly useful function, that one.

• 10 posts