| | 1 | | using System; |
| | 2 | | using System.Collections; |
| | 3 | | using System.Collections.Generic; |
| | 4 | | using Cinemachine; |
| | 5 | | using Cinemachine.Utility; |
| | 6 | | using DCL.Camera; |
| | 7 | | using UnityEngine; |
| | 8 | |
|
| | 9 | | public class SmoothAxisProvider : MonoBehaviour, AxisState.IInputAxisProvider |
| | 10 | | { |
| | 11 | | public Vector3 dampTime; |
| | 12 | |
|
| | 13 | | private Vector3 axis = new Vector3(); |
| | 14 | | private Vector3 axisTarget = new Vector3(); |
| | 15 | |
|
| | 16 | | public InputAction_Measurable axisX; |
| | 17 | | public InputAction_Measurable axisY; |
| | 18 | | private InputSpikeFixer[] inputSpikeFixer; |
| | 19 | |
|
| | 20 | | private void Awake() |
| | 21 | | { |
| 18 | 22 | | inputSpikeFixer = new [] |
| | 23 | | { |
| 8558 | 24 | | new InputSpikeFixer(() => Cursor.lockState), |
| 8576 | 25 | | new InputSpikeFixer(() => Cursor.lockState) |
| | 26 | | }; |
| 18 | 27 | | } |
| | 28 | | void Update() |
| | 29 | | { |
| 8553 | 30 | | axisTarget[0] = axisX.GetValue(); |
| 8553 | 31 | | axisTarget[1] = axisY.GetValue(); |
| 8553 | 32 | | axis += Damper.Damp(axisTarget - axis, dampTime, Time.deltaTime); |
| 8553 | 33 | | } |
| | 34 | |
|
| | 35 | | public float GetAxisValue(int axis) |
| | 36 | | { |
| 17098 | 37 | | return inputSpikeFixer[axis].GetValue(this.axis[axis]); |
| | 38 | | } |
| | 39 | | } |