diff --git a/Assets/InputSystem/StarterAssetsInputs.cs b/Assets/InputSystem/StarterAssetsInputs.cs index 7c5fe51..7e434cc 100644 --- a/Assets/InputSystem/StarterAssetsInputs.cs +++ b/Assets/InputSystem/StarterAssetsInputs.cs @@ -1,3 +1,5 @@ +using System; +using Unity.VisualScripting.Dependencies.NCalc; using UnityEngine; #if ENABLE_INPUT_SYSTEM && STARTER_ASSETS_PACKAGES_CHECKED using UnityEngine.InputSystem; @@ -14,12 +16,26 @@ namespace StarterAssets public bool _sprint; [Header("Movement Settings")] + [SerializeField] private float _mouseScale; public bool _analogMovement; [Header("Mouse Cursor Settings")] public bool _cursorLocked = true; public bool _cursorInputForLook = true; + public float MouseScale + { + get => _mouseScale; + set => _mouseScale = value; + } + + private void OnEnable() + { + _mouseScale = 1; + _cursorLocked = true; + SetCursorState(); + } + #if ENABLE_INPUT_SYSTEM && STARTER_ASSETS_PACKAGES_CHECKED public void OnMove(InputValue value) { @@ -32,7 +48,7 @@ namespace StarterAssets { if (Time.timeScale > 0) { - LookInput(value.Get()); + LookInput(_mouseScale * value.Get()); } else { @@ -58,12 +74,6 @@ namespace StarterAssets } #endif - private void OnEnable() - { - _cursorLocked = true; - SetCursorState(); - } - public void MoveInput(Vector2 newMoveDirection) { _move = newMoveDirection; diff --git a/Assets/Weapons/WeaponZoom.cs b/Assets/Weapons/WeaponZoom.cs index 23050f6..e48fc59 100644 --- a/Assets/Weapons/WeaponZoom.cs +++ b/Assets/Weapons/WeaponZoom.cs @@ -1,5 +1,6 @@ using System; using Cinemachine; +using StarterAssets; using Unity.VisualScripting; using UnityEngine; using UnityEngine.InputSystem; @@ -9,13 +10,17 @@ public class WeaponZoom : MonoBehaviour { [Header("Configuration")] [SerializeField] private float _fovNormal; + [SerializeField] private float _senseNormal; [SerializeField] private float _fovZoom; + [SerializeField] private float _senseZoom; + [SerializeField] private StarterAssetsInputs _input; [Header("State")] [SerializeField] private CinemachineVirtualCamera _camera; [SerializeField] private bool _zoomedIn; private void OnEnable() { + _input = GetComponent(); _camera = FindObjectOfType(); Debug.Assert(_camera != null, nameof(_camera) + " != null"); _fovNormal = _camera.m_Lens.FieldOfView; @@ -23,18 +28,18 @@ public class WeaponZoom : MonoBehaviour private void Update() { - if (Mouse.current.rightButton.wasPressedThisFrame) - { - _zoomedIn = !_zoomedIn; - } - + if (!Mouse.current.rightButton.wasPressedThisFrame) return; + _zoomedIn = !_zoomedIn; if (_zoomedIn) { + _input.MouseScale = _senseZoom; _camera.m_Lens.FieldOfView = _fovZoom; } else { + _input.MouseScale = _senseNormal; _camera.m_Lens.FieldOfView = _fovNormal; } + } } \ No newline at end of file