using UnityEngine
public class something : MonoBehaviour
{
public Transform camera;
public Rigidbody rb;
public float cameraRotationSpeed = 5f;
public float cameraMinimumY = -60f;
public float cameraMaximumY = 75f;
public float rotationSmoothSpeed = 10f;
public float walkSpeed = 9f;
public float runSpeed = 14f;
public float maxSpeed = 20f;
public float jumpPower = 30f;
public float extraGravity = 45f;
float bodyRotationX;
float camRotationY;
Vector3 directionIntentX;
Vector3 directionIntentY;
float speed;
public bool grounded;
void Update()
{
LookRotation();
}
void LookRotation()
{
Cursor.visible = false;
cursor.LockState = CursorLockMode.Locked;
//Get camera and body rotational vaslues
bodyRotationX += Input.GetAxis(“Mouse X”) * cameraRotationSpeed;
camRotationY += Input.GetAxis(“Mouse Y”) * cameraRotationSpeed;
//Stoping our Camera from rotating 360 degrees
camRotationY = Mathf.ClampcamRotationY, cameraMinimum);
//creat rotation targets and handle rotations of the body and camera
Quaternion camTargetRotation = Quaternion.Euler(-camRotationY, 0, 0);
Quaternion bodyTargetRotation = Quaternion.Euler(0, bodyRotationX, 0);
//handle rotations
transform.rotarion = Quaternion.Lerp(transform.rotation, bodyTargetRotation, Time.deltaTime * rotationSmoothSpeed);
camera.localRotation = Quaternion.Lerp(camera.localRotation, camTargetRotation, Time.deltaTime * rotationSmoothSpeed);
}
}
transform.rotarion near the bottom.