Created
September 16, 2021 00:23
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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