I can generate a random number between 1 and 3 fairly easy.
float x = Random.Range(1, 3);
But I am trying to generate a random number between 1 and 3, including 1 decimal place. i.e 1.0, 1.1, 1.2 - 2.8, 2.9, 3.0 Any help appreciate. I am finding no easy function to do this.
Note - I am using .cs script in Unity
You can multiply the result like this:
float result = rnd.Next(10, 31) * .1f;
This will result in a range from 1.0
to 3.0
, stepping by .1
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With