using UnityEngine;
public class PlayerController : MonoBehaviour
{
public float speed = 5f; // Velocidade do jogador
void Start()
{
// Esconde e trava o cursor
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
}
void Update()
{
// Movimento do jogador
float moveX = Input.GetAxis("Horizontal"); // A/D ou ← →
float moveZ = Input.GetAxis("Vertical"); // W/S ou ↑ ↓
Vector3 move = transform.right * moveX + transform.forward * moveZ;
transform.position += move * speed * Time.deltaTime;
// Alternar cursor com ESC
if (Input.GetKeyDown(KeyCode.Escape))
{
if (Cursor.lockState == CursorLockMode.Locked)
{
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
else
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
}
}
}
using UnityEngine;
public class PlayerController : MonoBehaviour
{
public float speed = 5f; // Velocidade do jogador
}