diff --git a/ml_amt/MotionTweaker.cs b/ml_amt/MotionTweaker.cs index 3debec3..79247eb 100644 --- a/ml_amt/MotionTweaker.cs +++ b/ml_amt/MotionTweaker.cs @@ -44,6 +44,7 @@ enum PoseState bool m_grounded = false; bool m_groundedRaw = false; bool m_moving = false; + bool m_locomotionOverride = false; bool m_ikOverrideCrouch = true; float m_crouchLimit = 0.65f; @@ -177,6 +178,7 @@ internal void OnAvatarClear() m_locomotionOffset = Vector3.zero; m_emoteActive = false; m_moving = false; + m_locomotionOverride = false; m_hipsToPlayer = Vector3.zero; m_avatarHips = null; m_viewPointHeight = 1f; @@ -282,7 +284,7 @@ internal void OnPlayspaceScale() void OnIKPreUpdate() { - bool l_legsOverride = false; + bool l_locomotionOverride = false; m_ikWeight = m_vrIk.solver.IKPositionWeight; m_locomotionWeight = m_vrIk.solver.locomotion.weight; @@ -300,31 +302,35 @@ void OnIKPreUpdate() m_vrIk.solver.locomotion.weight = 0f; m_vrIk.solver.leftLeg.useAnimatedBendNormal = true; m_vrIk.solver.rightLeg.useAnimatedBendNormal = true; - l_legsOverride = true; + l_locomotionOverride = true; } if(m_ikOverrideFly && MovementSystem.Instance.flying) { m_vrIk.solver.locomotion.weight = 0f; m_vrIk.solver.leftLeg.useAnimatedBendNormal = true; m_vrIk.solver.rightLeg.useAnimatedBendNormal = true; - l_legsOverride = true; + l_locomotionOverride = true; } if(m_ikOverrideJump && !m_grounded && !MovementSystem.Instance.flying) { m_vrIk.solver.locomotion.weight = 0f; m_vrIk.solver.leftLeg.useAnimatedBendNormal = true; m_vrIk.solver.rightLeg.useAnimatedBendNormal = true; - l_legsOverride = true; + l_locomotionOverride = true; } } bool l_solverActive = !Mathf.Approximately(m_vrIk.solver.IKPositionWeight, 0f); - if(l_legsOverride && l_solverActive && m_followHips && (!m_moving || (m_poseState == PoseState.Proning)) && m_inVR && !BodySystem.isCalibratedAsFullBody) + if(l_locomotionOverride && l_solverActive && m_followHips && (!m_moving || (m_poseState == PoseState.Proning)) && m_inVR && !BodySystem.isCalibratedAsFullBody) { m_vrIk.solver.plantFeet = false; ABI_RC.Systems.IK.IKSystem.VrikRootController.enabled = false; PlayerSetup.Instance._avatar.transform.localPosition = m_hipsToPlayer; } + + if(m_locomotionOverride && !l_locomotionOverride) + m_vrIk.solver.Reset(); + m_locomotionOverride = l_locomotionOverride; } void OnIKPostUpdate()