How do I pick random number?

Get help using Construct 2

Post » Wed Sep 03, 2014 2:50 pm

i would like to know how i can make the system pick a random number between 1 to 5 and store it in a global variable?
B
15
S
3
G
1
Posts: 111
Reputation: 1,664

Post » Wed Sep 03, 2014 4:12 pm

set the variable to
(round(random(1,5)))
and it will work fine
B
5
Posts: 24
Reputation: 271

Post » Wed Sep 03, 2014 10:56 pm

random(x)
Generate a random float from 0 to x, not including x. E.g. random(4) can generate 0, 2.5, 3.29293, but not 4. Use floor(random(4)) to generate just the whole numbers 0, 1, 2, 3.

random(a, b)
Generate a random float between a and b, including a but not including b.

ceil(x) Round up x e.g. ceil(5.1) = 6

floor(x) Round down x e.g. floor(5.9) = 5

round(x) Round x to the nearest whole number e.g. round(5.6) = 6
B
21
S
5
G
1
Posts: 102
Reputation: 1,746


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests