diff --git a/DesktopVRIK/DesktopVRIKSystem.cs b/DesktopVRIK/DesktopVRIKSystem.cs index d24d14a..7c25cd4 100644 --- a/DesktopVRIK/DesktopVRIKSystem.cs +++ b/DesktopVRIK/DesktopVRIKSystem.cs @@ -125,6 +125,7 @@ internal class DesktopVRIKSystem : MonoBehaviour public bool Setting_Enabled = true; public bool Setting_PlantFeet; public bool Setting_ResetFootsteps; + public bool Setting_ProneThrusting; public float Setting_BodyLeanWeight; public float Setting_BodyHeadingLimit; public float Setting_PelvisHeadingWeight; @@ -177,6 +178,7 @@ internal class DesktopVRIKSystem : MonoBehaviour float _ikWeightLerp = 1f; float _ikSimulatedRootAngle = 0f; float _locomotionWeight = 1f; + float _scaleDifference = 1f; // Last Movement Parent Info Vector3 _movementPosition; @@ -198,7 +200,7 @@ internal class DesktopVRIKSystem : MonoBehaviour DesktopVRIKMod.UpdateAllSettings(); } - + void Update() { if (avatarVRIK == null) return; @@ -241,10 +243,11 @@ internal class DesktopVRIKSystem : MonoBehaviour // Get Upright value Vector3 delta = avatarIKSolver.spine.headPosition - avatarTransform.position; Vector3 deltaRotated = Quaternion.Euler(0, avatarTransform.rotation.eulerAngles.y, 0) * delta; - float upright = Mathf.InverseLerp(0f, avatarIKSolver.spine.headHeight, deltaRotated.y); + float upright = Mathf.InverseLerp(0f, avatarIKSolver.spine.headHeight * _scaleDifference, deltaRotated.y); return upright > 0.85f; } + void UpdateLocomotionWeight() { float targetWeight = BodySystem.TrackingEnabled && BodySystem.TrackingLocomotionEnabled ? 1.0f : 0.0f; @@ -319,6 +322,8 @@ internal class DesktopVRIKSystem : MonoBehaviour scaleDifference ); + _scaleDifference = scaleDifference; + avatarIKSolver.Reset(); ResetDesktopVRIK(); return true; @@ -383,31 +388,29 @@ internal class DesktopVRIKSystem : MonoBehaviour avatarIKSolver.plantFeet = Setting_PlantFeet; // Apply custom VRIK solving effects - if (_ikWeightLerp > 0) - { - IKBodyLeaningOffset(); - IKBodyHeadingOffset(); - } + IKBodyLeaningOffset(_ikWeightLerp); + IKBodyHeadingOffset(_ikWeightLerp); } - void IKBodyLeaningOffset() + void IKBodyLeaningOffset(float weight) { // Emulate old VRChat hip movement if (Setting_BodyLeanWeight <= 0) return; - float weightedAngle = Setting_BodyLeanWeight * _ikWeightLerp; + if (Setting_ProneThrusting) weight = 1f; + float weightedAngle = Setting_BodyLeanWeight * weight; float angle = _cameraTransform.localEulerAngles.x; angle = angle > 180 ? angle - 360 : angle; Quaternion rotation = Quaternion.AngleAxis(angle * weightedAngle, avatarTransform.right); avatarIKSolver.spine.headRotationOffset *= rotation; } - void IKBodyHeadingOffset() + void IKBodyHeadingOffset(float weight) { // Make root heading follow within a set limit if (Setting_BodyHeadingLimit <= 0) return; - float weightedAngleLimit = Setting_BodyHeadingLimit * _ikWeightLerp; + float weightedAngleLimit = Setting_BodyHeadingLimit * weight; float deltaAngleRoot = Mathf.DeltaAngle(transform.eulerAngles.y, _ikSimulatedRootAngle); float absDeltaAngleRoot = Mathf.Abs(deltaAngleRoot); @@ -581,6 +584,8 @@ internal class DesktopVRIKSystem : MonoBehaviour void ConfigureVRIK() { + // Reset scale diffrence + _scaleDifference = 1f; VRIKUtils.ApplyScaleToVRIK ( avatarVRIK, diff --git a/DesktopVRIK/Main.cs b/DesktopVRIK/Main.cs index 09cfcea..cc3ed1c 100644 --- a/DesktopVRIK/Main.cs +++ b/DesktopVRIK/Main.cs @@ -39,6 +39,9 @@ public class DesktopVRIKMod : MelonMod public static readonly MelonPreferences_Entry EntryIKLerpSpeed = CategoryDesktopVRIK.CreateEntry("IK Lerp Speed", 10f, description: "Determines fast the IK & Locomotion weights blend after entering idle. Set to 0 to disable."); + public static readonly MelonPreferences_Entry EntryProneThrusting = + CategoryDesktopVRIK.CreateEntry("Prone Thrusting", false, description: "Allows Body Lean Weight to take affect while crouched or prone."); + public static readonly MelonPreferences_Entry EntryIntegrationAMT = CategoryDesktopVRIK.CreateEntry("AMT Integration", true, description: "Relies on AvatarMotionTweaker to handle VRIK Locomotion weights if available."); diff --git a/DesktopVRIK/Properties/AssemblyInfo.cs b/DesktopVRIK/Properties/AssemblyInfo.cs index 7264cb4..25bdf29 100644 --- a/DesktopVRIK/Properties/AssemblyInfo.cs +++ b/DesktopVRIK/Properties/AssemblyInfo.cs @@ -26,6 +26,6 @@ using System.Reflection; namespace NAK.Melons.DesktopVRIK.Properties; internal static class AssemblyInfoParams { - public const string Version = "4.1.4"; + public const string Version = "4.1.5"; public const string Author = "NotAKidoS"; } \ No newline at end of file