- Home /
Get angle of Vector2
I tried using Vector2.Angle(new Vector2(1, 0), vec);
, but it didn't work in all cases. Is there a better solution?
I ended up using Mathf.Atan2(vec.x, vec.y);
, and it works perfectly for my purposes.
Comment
A vector only has an angle relative to another vector. Or, relative to the world coordinate system. Please thoroughly explain what you're attempting to do and show us more code if possible, formatted using the 101/010 button.
Answer by alok-kr-029 · Mar 03, 2015 at 09:41 AM
If you are trying to get the angle of the game object you can get it by
Vector3 vec = Object.transform.eulerAngles;
where Object is the your gameObject
if your trying to assign an angle to game object you
Object.transform.eulerAngles= new Vector3(1,0,0);
You have to take vector3