diff --git a/Unity_OculusLipsync+Openface/Assets/Scripts/FaceAnimator.cs b/Unity_OculusLipsync+Openface/Assets/Scripts/FaceAnimator.cs index 14e27757..7a33313b 100644 --- a/Unity_OculusLipsync+Openface/Assets/Scripts/FaceAnimator.cs +++ b/Unity_OculusLipsync+Openface/Assets/Scripts/FaceAnimator.cs @@ -71,11 +71,14 @@ private void Update() curFrameBlendshapeVals = new Dictionary(); // Deal with the timestamps, head + eye positions and rots, etc. - Vector3 headRot = new Vector3(frameData.d[4] * Mathf.Rad2Deg, - -frameData.d[5] * Mathf.Rad2Deg, - 0);//frameData.d[6] * Mathf.Rad2Deg - float headRotCorrection = 0; - head_bone.transform.localRotation = Quaternion.Slerp(head_bone.transform.localRotation, Quaternion.Euler((headRot * headRotationMultiplier) + new Vector3(headRotCorrection, 0, 0)), Time.deltaTime * headRotationSpeed); + Vector3 headRot = new Vector3(frameData.d[3] * Mathf.Rad2Deg, // Represents Up/down in OpenFace + frameData.d[4] * Mathf.Rad2Deg, // Turn + frameData.d[5] * Mathf.Rad2Deg); // Tilt + // Convert world corrdinate of `headRot` into local one, using `head_bone` + Vector3 headRotLocal = head_bone.transform.InverseTransformDirection(headRot); + head_bone.transform.localRotation = Quaternion.Slerp(head_bone.transform.localRotation, + Quaternion.Euler(headRotLocal), + Time.deltaTime * headRotationSpeed); foreach (var blend in overallBlendshapes)