Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Lab Assistant
Original Poster
#1 Old 8th Nov 2014 at 8:51 PM Last edited by ArtUrlWWW : 11th Nov 2014 at 8:43 PM.
Default [SOLVED] Random
Hi.
How to get random float value with limit (for example, from 0.5f to 2.0f) in Sims 3?
Something like http://msdn.microsoft.com/ru-ru/lib...(v=vs.110).aspx ,
Code:
public double GetRandomNumber(double minimum, double maximum)
{ 
    Random random = new Random();
    return random.NextDouble() * (maximum - minimum) + minimum;
}

but for .Net 2.0, for Sims 3
Advertisement
Inventor
#2 Old 8th Nov 2014 at 10:06 PM
Sims3.Gameplay.Core.RandomUtil.GetFloat(float minValue, float maxValue);
Lab Assistant
Original Poster
#3 Old 9th Nov 2014 at 9:20 AM
Thanks!
Lab Assistant
Original Poster
#4 Old 11th Nov 2014 at 8:43 PM
And another solution:

Code:
public float GetRandomNumber(float minimum, float maximum)
        {
            Random random = new Random();
            double input = random.NextDouble() * (maximum - minimum) + minimum;
            float result = (float)input;
            if (float.IsPositiveInfinity(result))
            {
                result = float.MaxValue;
            }
            else if (float.IsNegativeInfinity(result))
            {
                result = float.MinValue;
            }

            return result;
        }
Back to top