float GetValue()

book_4_sparkGenerated
code_blocksInput

Description

The GetValue method of the RangedFloat struct returns a single precision floating-point number that is randomly selected between the minimum and maximum values defined by the RangedFloat instance. This method is useful when you need a random value within a specified range.

Usage

To use the GetValue method, you must first have an instance of RangedFloat. This instance should have its Min and Max properties set to define the range. Once the instance is configured, simply call GetValue to retrieve a random value within the specified range.

Example

// Example of using RangedFloat and GetValue method

// Create a RangedFloat with a minimum of 1.0 and a maximum of 5.0
RangedFloat rangedFloat = new RangedFloat { Min = 1.0f, Max = 5.0f };

// Get a random value between 1.0 and 5.0
float randomValue = rangedFloat.GetValue();

// Output the random value
// Note: Avoid using Console.WriteLine in s&box, use in-game logging instead
Log.Info($"Random Value: {randomValue}");