using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerController : MonoBehaviour
{
public float speed = 5f;
private Rigidbody2D rb;
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
void Update()
{
float moveX = 0f;
if (Keyboard.current.leftArrowKey.isPressed)
moveX = -1f;
else if (Keyboard.current.rightArrowKey.isPressed)
moveX = 1f;
rb.linearVelocity = new Vector2(moveX * speed, rb.linearVelocity.y);
}
}