InverseKinematics.SignedAngle C# (CSharp) Method

SignedAngle() public method

public SignedAngle ( Vector3 a, Vector3 b, Transform t ) : float
a Vector3
b Vector3
t Transform
return float
    public float SignedAngle(Vector3 a, Vector3 b, Transform t)
    {
        float angle = Vector3.Angle (a, b);

        // Use skeleton as root, change dir if the rotation is flipped
        Vector3 dir = (_skeleton && _skeleton.transform.localRotation.eulerAngles.y == 180.0f && _skeleton.transform.localRotation.eulerAngles.x == 0.0f) ? Vector3.forward : Vector3.back;
        float sign = Mathf.Sign (Vector3.Dot (dir, Vector3.Cross (a, b)));
        angle = angle * sign;
        // Flip sign if character is turned around
        angle *= Mathf.Sign(t.root.localScale.x);
        return angle;
    }