Skip to content

Instantly share code, notes, and snippets.

@JPBotelho
Last active September 28, 2017 20:00
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 JPBotelho/c49028e5a36ee716d364e193ed1eaa6d to your computer and use it in GitHub Desktop.
Save JPBotelho/c49028e5a36ee716d364e193ed1eaa6d to your computer and use it in GitHub Desktop.
A method that returns a direction from 2 Euler Angles.
// Y - Vertical
//XZ - Horizontal
public static Vector3 DirFromAngle (float xa, float ya)
{
float x = Mathf.Cos(xa * Mathf.Deg2Rad) * Mathf.Cos(ya * Mathf.Deg2Rad);
float y = Mathf.Sin(xa * Mathf.Deg2Rad);
float z = Mathf.Cos(xa * Mathf.Deg2Rad) * Mathf.Sin(ya * Mathf.Deg2Rad);
return new Vector3(x, y, z).normalized;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment