using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.PlayerLoop; [DefaultExecutionOrder(-100)] public class PlayerInputHandler : MonoBehaviour { public event EventHandler OnJumpTrigger; public float MoveAxis { get; private set; } private GameInputs _input; private bool _isReadyToClear; private void Awake() { _input = new GameInputs(); } private void OnEnable() { _input.Player.Enable(); } private void OnDisable() { _input.Player.Disable(); } private void Start() { _input.Player.Jump.performed += (InputAction.CallbackContext obj) => OnJumpTrigger?.Invoke(this, EventArgs.Empty); } private void Update() { ClearInput(); ProcessInput(); } private void FixedUpdate() { _isReadyToClear = true; } private void ProcessInput() { MoveAxis = _input.Player.Movement.ReadValue(); } private void ClearInput() { if (!_isReadyToClear) return; MoveAxis = 0f; _isReadyToClear = false; } }