79284789

Date: 2024-12-16 13:11:57
Score: 0.5
Natty:
Report link

using UnityEngine;

public class FirstPersonCamera : MonoBehaviour { public float mouseSensitivity = 100f;

float xRotation = 0f;

void Start()
{
    Cursor.lockState = CursorLockMode.Locked;
}

void Update()
{
    float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
    float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;

    xRotation -= mouseY;
    xRotation = Mathf.Clamp(xRotation, -90f, 90f);

    transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
    transform.Rotate(Vector3.up * mouseX);
}

}

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Deepak kumar