Files
PIM_Laba2/Assets/_Scripts/PlayerInput.cs
T
2026-05-25 20:45:05 +03:00

32 lines
650 B
C#

using UnityEngine;
public class PlayerInput : MonoBehaviour
{
public Vector3 MoveInput { get; private set; }
public bool JumpPressed { get; private set; }
private void Update()
{
float horizontal = Input.GetAxisRaw("Horizontal");
float vertical = Input.GetAxisRaw("Vertical");
MoveInput = new Vector3(horizontal, 0f, vertical).normalized;
if (Input.GetButtonDown("Jump"))
{
JumpPressed = true;
}
}
public bool ConsumeJump()
{
if (!JumpPressed)
{
return false;
}
JumpPressed = false;
return true;
}
}