@@ -83,7 +83,7 @@ internal void CalibrateAutomatically()
83
83
Vector3 leftFootPos = center . InverseTransformPoint ( _trackingRig . leftFoot . transform . position ) ;
84
84
Vector3 rightFootPos = center . InverseTransformPoint ( _trackingRig . rightFoot . transform . position ) ;
85
85
86
- ApplyCalibration ( center , _trackingRig . head , _trackingRig . headCalibration , new Vector3 ( 0 , playerEyeHeight , 0 ) , Quaternion . Inverse ( center . rotation ) * _trackingRig . head . transform . rotation ) ;
86
+ ApplyCalibration ( center , _trackingRig . head , _trackingRig . headCalibration , new Vector3 ( 0 , playerEyeHeight , 0 ) , Quaternion . identity ) ;
87
87
ApplyCalibration ( center , _trackingRig . pelvis , _trackingRig . pelvisCalibration , new Vector3 ( 0 , playerEyeHeight * kEyeHeightToPelvisHeightRatio , 0 ) , Quaternion . identity ) ;
88
88
ApplyCalibration ( center , _trackingRig . leftFoot , _trackingRig . leftFootCalibration , new Vector3 ( leftFootPos . x , 0 , 0 ) , Quaternion . Euler ( 0 , - 10f , 0 ) ) ;
89
89
ApplyCalibration ( center , _trackingRig . rightFoot , _trackingRig . rightFootCalibration , new Vector3 ( rightFootPos . x , 0 , 0 ) , Quaternion . Euler ( 0 , 10f , 0 ) ) ;
@@ -179,10 +179,15 @@ private Transform CreateCenter(Transform parent)
179
179
Transform center = new GameObject ( "Center" ) . transform ;
180
180
Transform head = _trackingRig . head . transform ;
181
181
182
+ // We want the user's head rotation to match the avatar's head directly rather than assuming whatever
183
+ // position they're in is forward. I'm not sure how I feel about doing that, but it's what VRChat does.
184
+ var rotation = Quaternion . LookRotation ( Vector3 . ProjectOnPlane ( head . forward , parent . up ) , parent . up ) ;
185
+ head . rotation = rotation ;
186
+
182
187
center . SetParent ( parent , false ) ;
183
188
center . SetPositionAndRotation (
184
189
head . TransformPoint ( new Vector3 ( 0 , 0 , - kEyeToHeadPivotOffset ) ) ,
185
- Quaternion . LookRotation ( Vector3 . ProjectOnPlane ( head . forward , parent . up ) , parent . up ) ) ;
190
+ rotation ) ;
186
191
187
192
// put center on the ground
188
193
center . localPosition = new Vector3 ( center . localPosition . x , 0 , center . localPosition . z ) ;
0 commit comments