How to randomize a whole number

Get help using Construct 2

Post » Fri Jan 06, 2012 11:52 am

How to randomize a whole number?

I had to be randomized a number from 1 to 3.

But thus appears in the text box:

3.5453500345

or 1.00004343

: (
Amilton Neves do Brasil. Criando jogos des de 1999.
B
30
S
8
G
6
Posts: 223
Reputation: 8,719

Post » Fri Jan 06, 2012 11:57 am

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.


Amilton Neves do Brasil. Criando jogos des de 1999.
B
30
S
8
G
6
Posts: 223
Reputation: 8,719

Post » Fri Jan 06, 2012 12:00 pm

Good post from Ashley HERE discusses this and explains why it should be done a particular way, and THIS LINK discusses how weighting would affect the results, which would probably be the same for floor.zenox982012-01-06 12:13:43
If your vision so exceeds your ability, then look to something closer.
Moderator
B
120
S
28
G
68
Posts: 4,843
Reputation: 48,287


Return to How do I....?

Who is online

Users browsing this forum: jul, nicklowkcmagic and 16 guests