using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerInput : MonoBehaviour { private float horizontalInput; private PlayerMovement playerMovement; private bool jumpPressed; void Start() { playerMovement = gameObject.GetComponent(); } void Update() { horizontalInput = Input.GetAxis("Horizontal"); if (!jumpPressed) { jumpPressed = Input.GetButtonDown("Jump"); } } private void FixedUpdate() { if(horizontalInput != 0f) { playerMovement.Move(horizontalInput); } if (jumpPressed) { playerMovement.Jump(); jumpPressed = false; } } }