diff --git a/Fika.Core/Coop/FreeCamera/FreeCamera.cs b/Fika.Core/Coop/FreeCamera/FreeCamera.cs index 2a91e9fe..f91bfd1d 100644 --- a/Fika.Core/Coop/FreeCamera/FreeCamera.cs +++ b/Fika.Core/Coop/FreeCamera/FreeCamera.cs @@ -3,6 +3,7 @@ using EFT; using Fika.Core.Coop.Components; using Fika.Core.Coop.Players; +using System; using System.Collections.Generic; using System.Linq; using UnityEngine; @@ -23,6 +24,7 @@ public class FreeCamera : MonoBehaviour public bool IsActive = false; private CoopPlayer CurrentPlayer; private bool isFollowing = false; + private bool leftMode = false; private bool disableInput = false; private KeyCode forwardKey = KeyCode.W; @@ -248,6 +250,17 @@ protected void Update() if (isFollowing) { + if (CurrentPlayer != null) + { + if (CurrentPlayer.MovementContext.LeftStanceEnabled && !leftMode) + { + SetLeftShoulderMode(true); + } + else if (!CurrentPlayer.MovementContext.LeftStanceEnabled && leftMode) + { + SetLeftShoulderMode(false); + } + } return; } @@ -323,6 +336,36 @@ protected void Update() transform.localEulerAngles = new Vector3(newRotationY, newRotationX, 0f); } + private void SetLeftShoulderMode(bool enabled) + { + if (enabled) + { + // Use different coordinates for headcam + if (transform.localPosition.z == -0.17f) + { + transform.localPosition = new(transform.localPosition.x, transform.localPosition.y, -transform.localPosition.z); + } + else + { + transform.localPosition = new(-transform.localPosition.x, transform.localPosition.y, transform.localPosition.z); + } + leftMode = true; + } + else + { + // Use different coordinates for headcam + if (transform.localPosition.z == 0.17f) + { + transform.localPosition = new(transform.localPosition.x, transform.localPosition.y, -transform.localPosition.z); + } + else + { + transform.localPosition = new(-transform.localPosition.x, transform.localPosition.y, transform.localPosition.z); + } + leftMode = false; + } + } + private void ToggleVision() { NightVision nightVision = CameraClass.Instance.NightVision; @@ -353,6 +396,7 @@ public void JumpToPlayer() if (isFollowing) { isFollowing = false; + leftMode = false; transform.parent = null; } } @@ -425,6 +469,7 @@ public void SetActive(bool status) IsActive = status; isFollowing = false; + leftMode = false; transform.parent = null; }