Description
The Vector2.Random
property provides a static method to generate a random 2D vector. This vector is uniformly sampled from all points within a unit circle centered at the origin, meaning the distance from the origin to the point is at most 1. This is useful for generating random directions or positions within a bounded area in 2D space.
Usage
To use the Vector2.Random
property, simply access it directly since it is a static property. It does not require any parameters and will return a Vector2
object representing a random point within a unit circle.
Example
// Example of using Vector2.Random
Vector2 randomVector = Vector2.Random;
// Output the random vector
// Note: The actual values will vary each time you run this
Console.WriteLine($"Random Vector: {randomVector.x}, {randomVector.y}");