using UnityEngine;
[RequireComponent(typeof(Rigidbody))]
public class PlayerMovement : MonoBehaviour
{
public float speed = 10f; // Velocidade de movimento
public float mouseSensitivity = 200f; // Sensibilidade do mouse
public float jumpForce = 5f; // For�a do pulo
private float rotationY = 0f; // Rota��o horizontal
private Rigidbody rb;
private bool isGrounded = true; // Verifica se est� no ch�o
void Start()
{
rb = GetComponent<Rigidbody>();
[Link] = true; // Impede que o player tombe ao colidir
}
void Update()
{
// --- Movimento ---
float moveX = [Link]("Horizontal");
float moveZ = [Link]("Vertical");
Vector3 move = [Link] * moveX + [Link] * moveZ;
Vector3 moveVelocity = move * speed;
[Link] = new Vector3(moveVelocity.x, [Link].y,
moveVelocity.z);
// --- Rota��o com o mouse ---
float mouseX = [Link]("Mouse X") * mouseSensitivity * [Link];
rotationY += mouseX;
[Link] = [Link](0f, rotationY, 0f);
// --- Pulo (barra de espa�o) ---
if ([Link]([Link]) && isGrounded)
{
[Link]([Link] * jumpForce, [Link]);
isGrounded = false;
}
}
// Detecta se o player voltou ao ch�o
void OnCollisionEnter(Collision collision)
{
if ([Link]("Ground"))
{
isGrounded = true;
}
}
}