Added floating avatar correction
This commit is contained in:
parent
a055ff337a
commit
69a1ed2fff
@ -712,6 +712,7 @@ namespace Passer {
|
||||
CalibrateAtStartSetting();
|
||||
StartPositionSetting();
|
||||
ScalingSetting();
|
||||
FloatCorrectionSetting();
|
||||
DontDestroySetting();
|
||||
if (IsPrefab(humanoid))
|
||||
DisconnectInstancesSetting();
|
||||
@ -770,6 +771,15 @@ namespace Passer {
|
||||
scalingProp.intValue = (int)(HumanoidControl.ScalingType)EditorGUILayout.EnumPopup(text, (HumanoidControl.ScalingType)scalingProp.intValue);
|
||||
}
|
||||
|
||||
protected void FloatCorrectionSetting() {
|
||||
SerializedProperty floatCorrectionProp = serializedObject.FindProperty(nameof(HumanoidControl.floatCorrection));
|
||||
GUIContent text = new GUIContent(
|
||||
"Float Correction",
|
||||
"Correct floating avatars when user is taller than the avatar"
|
||||
);
|
||||
floatCorrectionProp.boolValue = EditorGUILayout.Toggle(text, floatCorrectionProp.boolValue);
|
||||
}
|
||||
|
||||
private void ShowTrackers(HumanoidControl humanoid, bool shown) {
|
||||
foreach (Tracker tracker in humanoid.trackers)
|
||||
tracker.ShowTracker(shown);
|
||||
|
@ -2112,6 +2112,12 @@ namespace Passer.Humanoid {
|
||||
// So probably this setting should only be used when using animations.
|
||||
public bool useLegLengthCorrection = false;
|
||||
private float legLengthCorrection = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Correct floating avatars when user is taller than the avatar
|
||||
/// </summary>
|
||||
public bool floatCorrection = false;
|
||||
|
||||
protected void CheckGrounded() {
|
||||
Vector3 footBase = GetHumanoidPosition();
|
||||
//footBase += legLengthBias * Vector3.up;
|
||||
@ -2146,6 +2152,13 @@ namespace Passer.Humanoid {
|
||||
|
||||
legLengthCorrection = 0.99F * legLengthCorrection + 0.01F * footBoneDistance.y;
|
||||
}
|
||||
|
||||
if (floatCorrection) {
|
||||
float leftFootBoneDistance = leftFootTarget.foot.bone.transform.position.y - leftFootTarget.foot.target.transform.position.y;
|
||||
float rightFootBoneDistance = rightFootTarget.foot.bone.transform.position.y - rightFootTarget.foot.target.transform.position.y;
|
||||
if (leftFootBoneDistance > 0.02F && rightFootBoneDistance > 0.02F)
|
||||
AdjustTrackingHeight(-0.01F);
|
||||
}
|
||||
}
|
||||
|
||||
public float GetDistanceToGroundAt(Vector3 position, float maxDistance) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user