I want to turn a degree into a vector. I manually coded it myself by converting the degree to radians, and getting the components manually like so:
float degree = 70.0f;
float radians = degree * (Mathf.PI / 180);
Vector3 degreeVector = new Vector3(Mathf.Cos(radians), Mathf.Sin(radians), 0);
I dont bother with the Z coordinate since i am only dealing in two dimensions. Anyway, given that there are ways of turning a vector into an angle with Vector3.Angle(), there has to be a simpler way of doing this. Does anyone know how?
If there isn’t a built-in method to do this, just create your own wrapping helper method to do it.
Thanks for the suggestion. I know I can do that, but thats why I am checking on the forum first. Hate to reinvent the wheel ya know? Plus it seems to me like that sort of functionality should already exist if they have ways of turning vectors into degrees.
This might be what you’re looking for:
Then I guess you would hit up another one of its members to make a vector.
Seeing as you’re using a special case (2 dimensional instead of 3), I wouldn’t count on there being an easier and faster way in the existing API. Though if there is, super!
I just think it is something simple enough where it should be included in the Vector3 class. Plus I am sure there are ways of handling this for 3D applications like specifying an up-vector and a right-vector along with the degrees. As for creating a Quaternion and converting it to a vector, that seems like too much overhead. Thanks for the suggestion though. I guess I will just go with FizixMan’s suggestion in the mean time. Thanks guys.