So i made a script that allows you to rotate your camera but i just want it to work while the first mouse button is down and i want the mouse to stay in one place, here is my code:
private const float Y_ANGLE_MIN = 0f;
private const float Y_ANGLE_MAX = 50f;
public Transform lookAt;
public Transform camTransform;
private Camera cam;
private float distance = 10f;
private float currentX = 0f;
private float currentY = 0f;
private float sensivityX = 4f;
private float sensivityY = 1f;
private void Start()
{
camTransform = transform;
cam = Camera.main;
}
private void Update() {
currentX += Input.GetAxis("Mouse X");
currentY += Input.GetAxis("Mouse Y");
currentY = Mathf.Clamp(currentY, Y_ANGLE_MIN, Y_ANGLE_MAX);
}
private void LateUpdate() {
Vector3 dir = new Vector3(0, 0, -distance);
Quaternion rotation = Quaternion.Euler(currentY,currentX,0);
camTransform.position = lookAt.position + rotation * dir;
camTransform.LookAt(lookAt.position);
}