diff --git a/GorillaTagLIV/Plugin.cs b/GorillaTagLIV/Plugin.cs index fe6878b..1dc095c 100644 --- a/GorillaTagLIV/Plugin.cs +++ b/GorillaTagLIV/Plugin.cs @@ -15,6 +15,8 @@ public class Plugin : BaseUnityPlugin { private const string assetsDir = "/BepInEx/plugins/GorillaTagLIV/Assets/"; private Camera thirdPersonCamera; + private Quaternion livCameraRotation; + private Vector3 livCameraPosition; private LIV.SDK.Unity.LIV liv; @@ -85,6 +87,8 @@ private void SetUpThridPersonCamera() if (cinemachineBrain) { thirdPersonCamera = cinemachineBrain.GetComponent(); + livCameraRotation = thirdPersonCamera.transform.localRotation; + livCameraPosition = thirdPersonCamera.transform.localPosition; } } @@ -101,7 +105,14 @@ private void Update() if (!liv || !thirdPersonCamera || !liv.isActive) return; var cameraTransform = thirdPersonCamera.transform; - liv.render.SetPose(cameraTransform.position, cameraTransform.rotation, thirdPersonCamera.fieldOfView); + + livCameraRotation = Quaternion.Slerp(livCameraRotation, cameraTransform.localRotation, Quaternion.Angle(livCameraRotation, cameraTransform.localRotation) / 180f); + livCameraPosition = Vector3.Slerp(livCameraPosition, cameraTransform.localPosition, (livCameraPosition - cameraTransform.localPosition).sqrMagnitude / 10f); + + liv.render.SetPose( + cameraTransform.parent.TransformPoint(livCameraPosition), + cameraTransform.parent.rotation * livCameraRotation, + thirdPersonCamera.fieldOfView); } } }