Quaternion.Angle and 360 degrees

Hi!

I need to receive a angle between rotations of two objects from 0 to 360 degrees. However the function "Quaternion.Angle" produces value from 0 to 180.

``````public GameObject Object1, Object2;
void Update () {
Object1.transform.Rotate (Vector3.up * 10 * Time.deltaTime);
float angle = Quaternion.Angle (Object1.transform.rotation,
Object2.transform.rotation);
Debug.Log (angle);
}

``````

Thanks.

you can fix one time dot product of these two GameObject forward dot product Vector3 up = dot(object1.transform.forward, object2.transform.forward); and ever@ interpolate state compare direction dot with up (in normalize mode), it must be same vector or invert vector, if dot is invert vector that mean (angle = 360 - angle)

``````void Start() {
Vector3 right = object2.transform.TransformDirection(Vector3.right);
Vector3 up = Vector3.dor(object2.transform.TransformDirection(Vector3.forward), right);
}

void Update() {
Object1.transform.Rotate (Vector3.up * 10 * Time.deltaTime);
Vector3 newup = Vector3.dor(object2.transform.TransformDirection(Vector3.forward), object1.transform.TransformDirection(Vector3.forward));
float angle = Quaternion.Angle (Object1.transform.rotation,
Object2.transform.rotation);
if (up.normalized != newup.normalized) {
angle = 360 - angle;
}
}

``````

not tested.