Game Development Community

Generate random float number

by andrisalim · in General Discussion · 06/15/2011 (11:39 pm) · 1 replies

Hi guys, how do you actually generate a random float value?
I saw there is getRandom(a,b); function where a and b are int and the returned value is float. Do I need to convert the returned to float by myself? Because I have gotten no float number from the returned value...

About the author

Torque is new and interesting to me. I am keen in learning and sharpening my knowledge of Torque, especially Torque 3D which I am currently working with. :) Cheers, Andri Salim


#1
06/23/2011 (7:12 pm)
I experimented a little in the little console and it appears getRandom() does what you want. I think that you're thinking about types a little too much for working with TorqueScript. Nothing is static type.

Anyway, getRandom(%a, %b) returns an integer between %a and %b inclusive. getRandom() returns a float from 0.0 to 1.0.