Last active
September 28, 2017 20:00
-
-
Save JPBotelho/c49028e5a36ee716d364e193ed1eaa6d to your computer and use it in GitHub Desktop.
A method that returns a direction from 2 Euler Angles.
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
// 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