Skip to content

Commit 2ee8156

Browse files
committed
feat(Util): Add random in sphere
1 parent 0c359ea commit 2ee8156

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Assets/JCSUnity/Scripts/Util/JCS_Random.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,5 +129,14 @@ public static Vector3 PointInBounds(Bounds bounds)
129129
Range(bounds.min.y, bounds.max.y),
130130
Range(bounds.min.z, bounds.max.z));
131131
}
132+
133+
/// <summary>
134+
/// Return a random position in sphere.
135+
/// </summary>
136+
public static Vector3 PointInSphere(Vector3 centerPosition, float radius)
137+
{
138+
Vector3 randomPoint = Random.insideUnitSphere * radius;
139+
return centerPosition + randomPoint;
140+
}
132141
}
133142
}

0 commit comments

Comments
 (0)