Random Velocity Decimals

We are creating games to finish Unit 3 of CS Discoveries. I’m having trouble creating random sprite velocities that are decimals. Looking at the debug console, it appears to round to whole numbers, including 0. So if I put a range of .1 and 2 into the random number min and max for a sprite velocity, it will sometimes go to 0, sometimes 1 & sometimes 2, but never a decimal. I then thought velocities had to be whole numbers but if I just enter .5 as a velocity that works just fine. So is there anyway to create a range of random velocities that include decimals? Thanks.


Hi @sam.barnhart,

You’re right – randomNumber generates an integer. If you were to generate an integer between, say, 0 and 20, is there a way you could store that number and then manipulate it to get a decimal?

Let us know if you need more help with this one.

–Michael K.