using UnityEngine; public class PlayerController : MonoBehaviour { [SerializeField] private float moveSpeed = 5f; [SerializeField] private float rotationSpeed = 720f; private InputSystem_Actions _inputActions; private void Awake() { _inputActions = new InputSystem_Actions(); } private void OnEnable() { _inputActions.Player.Enable(); } private void OnDisable() { _inputActions.Player.Disable(); } private void Update() { var moveInput = _inputActions.Player.Move.ReadValue(); var direction = new Vector3(moveInput.x, 0f, moveInput.y); direction = Vector3.ClampMagnitude(direction, 1f); transform.position += direction * moveSpeed * Time.deltaTime; if (direction == Vector3.zero) return; var targetRotation = Quaternion.LookRotation(direction); transform.rotation = Quaternion.RotateTowards( transform.rotation, targetRotation, rotationSpeed * Time.deltaTime); } }