> For the complete documentation index, see [llms.txt](https://kinematicsoup.gitbook.io/reactor/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kinematicsoup.gitbook.io/reactor/api-reference/ks.reactor/ks.reactor.ksrandom.md).

# Class ksRandom

Namespace: [KS.Reactor](/reactor/api-reference/ks.reactor.md)\
Assembly: KSCommon.dll

Extends the built-in C# Random class with methods for generating floats, vectors, and quaternions.

```csharp
public class ksRandom : Random
```

#### Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) ← [Random](https://learn.microsoft.com/dotnet/api/system.random) ← [ksRandom](/reactor/api-reference/ks.reactor/ks.reactor.ksrandom.md)

#### Inherited Members

[Random.Next()](https://learn.microsoft.com/dotnet/api/system.random.next#system-random-next), [Random.Next(int)](https://learn.microsoft.com/dotnet/api/system.random.next#system-random-next\(system-int32\)), [Random.Next(int, int)](https://learn.microsoft.com/dotnet/api/system.random.next#system-random-next\(system-int32-system-int32\)), [Random.NextBytes(byte\[\])](https://learn.microsoft.com/dotnet/api/system.random.nextbytes#system-random-nextbytes\(system-byte\(\)\)), [Random.NextBytes(Span\<byte>)](https://learn.microsoft.com/dotnet/api/system.random.nextbytes#system-random-nextbytes\(system-span\(\(system-byte\)\)\)), [Random.NextDouble()](https://learn.microsoft.com/dotnet/api/system.random.nextdouble), [Random.Sample()](https://learn.microsoft.com/dotnet/api/system.random.sample), [object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object\)), [object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object-system-object\)), [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode), [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype), [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone), [object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals), [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Constructors

### ksRandom() <a href="#ks_reactor_ksrandom__ctor" id="ks_reactor_ksrandom__ctor"></a>

Constructor. Initializes the seed to a random value.

```csharp
public ksRandom()
```

### ksRandom(int) <a href="#ks_reactor_ksrandom__ctor_system_int32" id="ks_reactor_ksrandom__ctor_system_int32"></a>

Constructor.

```csharp
public ksRandom(int seed)
```

#### Parameters

`seed` [int](https://learn.microsoft.com/dotnet/api/system.int32)

Seed for pseudo-random sequence.

## Properties

### Seed <a href="#ks_reactor_ksrandom_seed" id="ks_reactor_ksrandom_seed"></a>

Initial seed.

```csharp
public int Seed { get; }
```

#### Property Value

[int](https://learn.microsoft.com/dotnet/api/system.int32)

## Methods

### NextFloat() <a href="#ks_reactor_ksrandom_nextfloat" id="ks_reactor_ksrandom_nextfloat"></a>

Random value between 0 (inclusive) and 1 (exclusive).

```csharp
public float NextFloat()
```

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### NextFloat(float, float) <a href="#ks_reactor_ksrandom_nextfloat_system_single_system_single" id="ks_reactor_ksrandom_nextfloat_system_single_system_single"></a>

Returns a random float within a range.

```csharp
public float NextFloat(float min, float max)
```

#### Parameters

`min` [float](https://learn.microsoft.com/dotnet/api/system.single)

Min value (inclusive).

`max` [float](https://learn.microsoft.com/dotnet/api/system.single)

Max value (exclusive)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

Random number in the range.

### NextQuaternion() <a href="#ks_reactor_ksrandom_nextquaternion" id="ks_reactor_ksrandom_nextquaternion"></a>

Random quaternion.

```csharp
public ksQuaternion NextQuaternion()
```

#### Returns

[ksQuaternion](/reactor/api-reference/ks.reactor/ks.reactor.ksquaternion.md)

### NextUnitVector2() <a href="#ks_reactor_ksrandom_nextunitvector2" id="ks_reactor_ksrandom_nextunitvector2"></a>

Random vector2 with magnitude 1.

```csharp
public ksVector2 NextUnitVector2()
```

#### Returns

[ksVector2](/reactor/api-reference/ks.reactor/ks.reactor.ksvector2.md)

### NextUnitVector3() <a href="#ks_reactor_ksrandom_nextunitvector3" id="ks_reactor_ksrandom_nextunitvector3"></a>

Random vector3 with magnitude 1.

```csharp
public ksVector3 NextUnitVector3()
```

#### Returns

[ksVector3](/reactor/api-reference/ks.reactor/ks.reactor.ksvector3.md)

### NextVector2() <a href="#ks_reactor_ksrandom_nextvector2" id="ks_reactor_ksrandom_nextvector2"></a>

Random vector3 with magnitude less than 1.

```csharp
public ksVector2 NextVector2()
```

#### Returns

[ksVector2](/reactor/api-reference/ks.reactor/ks.reactor.ksvector2.md)

### NextVector2(float, float) <a href="#ks_reactor_ksrandom_nextvector2_system_single_system_single" id="ks_reactor_ksrandom_nextvector2_system_single_system_single"></a>

Returns a random vector2 with magnitude within a range.

```csharp
public ksVector2 NextVector2(float minMagnitude, float maxMagnitude)
```

#### Parameters

`minMagnitude` [float](https://learn.microsoft.com/dotnet/api/system.single)

Min magnitude (inclusive).

`maxMagnitude` [float](https://learn.microsoft.com/dotnet/api/system.single)

Max magnitude (exclusive).

#### Returns

[ksVector2](/reactor/api-reference/ks.reactor/ks.reactor.ksvector2.md)

Random vector2 with magnitude within the range.

### NextVector3() <a href="#ks_reactor_ksrandom_nextvector3" id="ks_reactor_ksrandom_nextvector3"></a>

Random vector3 with magnitude less than 1.

```csharp
public ksVector3 NextVector3()
```

#### Returns

[ksVector3](/reactor/api-reference/ks.reactor/ks.reactor.ksvector3.md)

### NextVector3(float, float) <a href="#ks_reactor_ksrandom_nextvector3_system_single_system_single" id="ks_reactor_ksrandom_nextvector3_system_single_system_single"></a>

Returns a random vector3 with magnitude within a range.

```csharp
public ksVector3 NextVector3(float minMagnitude, float maxMagnitude)
```

#### Parameters

`minMagnitude` [float](https://learn.microsoft.com/dotnet/api/system.single)

Min magnitude(inclusive).

`maxMagnitude` [float](https://learn.microsoft.com/dotnet/api/system.single)

Max magnitude(exclusive).

#### Returns

[ksVector3](/reactor/api-reference/ks.reactor/ks.reactor.ksvector3.md)
