Вращение камеры мышью Unity 3D

Пытаюсь реализовать вращение камеры внутри объекта (Сфера, с инвертированным видом материала, так чтобы он показывался внутри нее, для фото в 360). Камера или объект должны вращаться на расстояние которое прошла мыщь.

Сейчас-же камера не перестает вращаться, если остановить мышь. Не знаю как это поправить. подскажите, пожалуйста.

Quaternion originRotate;
float angleHorizontal;
float angleVertical;

public float mouseSens = 1;
// Start is called before the first frame update
void Start(){
    originRotate = transform.rotation;
}

// Update is called once per frame
void FixedUpdate() {
    // if (Input.touchCount == 1){
    if (Input.GetMouseButton(0)){
        originRotate = transform.rotation;
        angleHorizontal+=Input.GetAxis("Mouse X") * mouseSens;
        angleVertical+=Input.GetAxis("Mouse Y") * mouseSens;

        // Vertical rotation limitation
        angleVertical = Mathf.Clamp(angleVertical, -55, 55); 

        Quaternion rotationY = Quaternion.AngleAxis(-angleHorizontal, Vector3.up);
        Quaternion rotationX = Quaternion.AngleAxis(angleVertical, Vector3.right);

        transform.rotation = originRotate * rotationY * rotationX;
    }

    if (Input.GetMouseButtonUp(0)){
    originRotate = transform.rotation;
    }
}

Ответы (1 шт):

Автор решения: Михаил

Попробуйте посмотреть этот видео-урок с YouTube или использовать cinemachine.

→ Ссылка