Hundreds of features to explore
Games made in Construct
Your questions answered
Trusted by schools and universities worldwide
Free education resources to use in the classroom
Students do not need accounts with us
What we believe
We are in this together
World class complete documentation
Official and community submitted guides
Learn and share with other game developers
Upload and play games from the Construct community
Game development stories & opinions
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
: (
Develop games in your browser. Powerful, performant & highly capable.
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.
<img src="smileys/smiley32.gif" border="0" align="middle" />
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.