Hi I have the following code which gives me an angle of direction between two vectors. However, the angle is only ever 0 to 180, whether the direction is on the left, or the right of the scripted object. I need it to go from 0 to 360 so that I can clearly indentify whether the direction is to the left, right, back, front etc. Code (CSharp): public void SetDirection(Vector2 newDirection) { Vector2 tempLocation = transform.localPosition; Vector2 tempVector = newDirection - tempLocation; float angleRadians = Mathf.Atan2(tempVector.y, tempVector.x); angleDegrees= angleRadians * Mathf.Rad2Deg; } angleDegrees is only ever 0 to 180. Need it to be 0 to 360. Any ideas?
it goes from -180 to 180, check for the negative values. if you really want it to be 0 through 360 add 180 to your final angle
@oliver_unity892 And you can also use Vector3.SignedAngle: https://docs.unity3d.com/ScriptReference/Vector3.SignedAngle.html You don't necessarily have to use Atan2.