using UnityEngine;
public class MouseLookAround : MonoBehaviour
{
float rotationX = 0f;
float rotationY = 0f;
public Transform playerBody;
public Vector2 sensitivity = Vector2.one * 100f;
private void Start() {
Cursor.lockState = CursorLockMode.Locked;
}
void Update()
{
// Mouse hareketlerine göre dönüş açısını güncelleme
rotationY = Input.GetAxis("Mouse X") * sensitivity.x * Time.deltaTime;
rotationX -= Input.GetAxis("Mouse Y") * sensitivity.y * Time.deltaTime; // Burada - ekleyerek ters yönü düzeltiyoruz
// rotationX'i sınırlama (örneğin, dikey eksende 90 derece ile sınırlandırabiliriz)
rotationX = Mathf.Clamp(rotationX, -90f, 90f);
// Dönüşü Quaternions ile ayarlama
transform.localRotation = Quaternion.Euler(rotationX, 0, 0);
playerBody.Rotate(Vector3.up * rotationY);
}
}