[AlternateIKSystem] Fix offset issues

This commit is contained in:
NotAKidoS 2023-07-14 03:37:53 -05:00
parent 9847827813
commit 99c0256ed3
4 changed files with 20 additions and 26 deletions

View file

@ -1,6 +1,5 @@
using RootMotion.FinalIK;
using UnityEngine;
using Valve.VR;
using Object = UnityEngine.Object;
namespace NAK.AlternateIKSystem.IK;

View file

@ -1,6 +1,4 @@
using ABI.CCK.Components;
using NAK.AlternateIKSystem.VRIKHelpers;
using RootMotion.FinalIK;
using RootMotion.FinalIK;
using UnityEngine;
namespace NAK.AlternateIKSystem.IK.IKHandlers;

View file

@ -1,6 +1,4 @@
using ABI.CCK.Components;
using NAK.AlternateIKSystem.VRIKHelpers;
using RootMotion.FinalIK;
using RootMotion.FinalIK;
using UnityEngine;
namespace NAK.AlternateIKSystem.IK.IKHandlers;

View file

@ -6,7 +6,6 @@ using NAK.AlternateIKSystem.VRIKHelpers;
using RootMotion.FinalIK;
using UnityEngine;
using UnityEngine.Events;
using Object = System.Object;
namespace NAK.AlternateIKSystem.IK;
@ -42,9 +41,9 @@ public class IKManager : MonoBehaviour
private Transform _rightHandTarget;
private Transform _rightHandRotations;
// Hand Anchor Offsets
private readonly Vector3 _handAnchorPositionOffset = new Vector3(-0.038f, 0.0389f, -0.138f);
private readonly Vector3 _handAnchorRotationOffset = new Vector3(55, 10, 50);
// Hand Anchor Offsets (the magic numbers that make or break the game)
private readonly Vector3 _handAnchorPositionOffset = new Vector3(-0.048f, 0.0389f, -0.138f);
private readonly Vector3 _handAnchorRotationOffset = new Vector3(70f, 0f, 50f);
// Avatar Info
private Animator _animator;
@ -240,10 +239,10 @@ public class IKManager : MonoBehaviour
private void SetupIkGeneral()
{
_animator.transform.position = GetPlayerPosition();
_animator.transform.rotation = GetPlayerRotation();
SetAvatarPose(AvatarPose.Default);
_vrik = IKCalibrator.SetupVrIk(_animator);
_vrik.transform.position = GetPlayerPosition();
_vrik.transform.rotation = GetPlayerRotation();
}
private void InitializeIkGeneral()
@ -252,11 +251,11 @@ public class IKManager : MonoBehaviour
VRIKUtils.CalculateInitialIKScaling(_vrik, ref _ikHandler._locomotionData);
VRIKUtils.CalculateInitialFootsteps(_vrik, ref _ikHandler._locomotionData);
_vrik.solver.Initiate(_vrik.transform); // initiate a second time
VRIKUtils.ApplyScaleToVRIK(_vrik, _ikHandler._locomotionData, 1f);
SetAvatarPose(AvatarPose.Initial);
VRIKUtils.ApplyScaleToVRIK(_vrik, _ikHandler._locomotionData, 1f);
_vrik.onPreSolverUpdate.AddListener(new UnityAction(OnPreSolverUpdateGeneral));
_vrik.onPostSolverUpdate.AddListener(new UnityAction(OnPostSolverUpdateGeneral));
}