Fix NextUnitVector2 degree to radian

Fixes the use of degrees when radians should be used.
This commit is contained in:
rkrahn
2024-02-19 13:00:38 -08:00
committed by GitHub
parent 0b2fcff4ea
commit 4ad5eb26d6
+2 -2
View File
@@ -298,8 +298,8 @@ namespace FlaxEngine.Utilities
public static Vector2 NextUnitVector2(this Random random, float radius = 1.0f)
{
float magnitude = (float)random.NextDouble() * radius;
double randomDegree = random.NextDouble() * 360;
return new Vector2((float)Math.Cos(randomDegree) * magnitude, (float)Math.Sin(randomDegree) * magnitude);
double randomRadian = random.NextDouble() * Mathf.RevolutionsToRadians;
return new Vector2((float)Math.Cos(randomRadian) * magnitude, (float)Math.Sin(randomRadian) * magnitude);
}
/// <summary>