Skip to content

Instantly share code, notes, and snippets.

@clavis-magna
Created August 29, 2019 10:04
Show Gist options
  • Save clavis-magna/2134fad715fc4f3352f6654d030d1ced to your computer and use it in GitHub Desktop.
Save clavis-magna/2134fad715fc4f3352f6654d030d1ced to your computer and use it in GitHub Desktop.
[Unity c#] given an angle and a radius, get a cartesian co-ordinate
// what is the position on a circumference?
// given a radius of 'radius'
// need to make relative to the object when touched
// eg: (x, y) = (12 * sin(115.toRadian), 12 * cos(115.toRadian))
float xPosOnradius = radius * Mathf.Sin(degree * Mathf.Deg2Rad) + transform.position.x;
float zPosOnradius = radius * Mathf.Cos(degree * Mathf.Deg2Rad) + transform.position.z;
float yPos = this.transform.position.y;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment