Skip to content

Instantly share code, notes, and snippets.

@mminer
Created September 16, 2021 00:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mminer/ef2e627b93a51d6abb29b00f730e3a53 to your computer and use it in GitHub Desktop.
Save mminer/ef2e627b93a51d6abb29b00f730e3a53 to your computer and use it in GitHub Desktop.
Unity function to get a random point on a unit circle, similar to Random.onUnitSphere.
static Vector2 RandomPointOnUnitCircle()
{
var angle = Random.Range(0f, Mathf.PI * 2);
var x = Mathf.Sin(angle);
var y = Mathf.Cos(angle);
return new Vector2(x, y);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment