How to make third person cinemachine camera rotate up/down with vertical mouse position

Hello I am working on a third person game and I can’t figure out how to make the third person camera from cinemachine angle with the mouse Y position from the new input system .
How do i change my camera euler angle ?

    private void TurnWithMouse()
    {
        xRotation -= mousePosition.y;
        xRotation = Mathf.Clamp(xRotation, -30f, 50f);
        Vector3 targetRotation = head.transform.eulerAngles;
        targetRotation.x = xRotation;
        head.eulerAngles = targetRotation;
        playerCamera.eulerAngles = targetRotation;
  /*       Debug.Log(playerCamera.eulerAngles);*/
        transform.Rotate(Vector3.up, mousePosition.x * Time.deltaTime * mouseSensitivityX);
    }


Hi
Could you show us your virtual camera?
The solution depends on what kind of vcam/setup you have.

In general, your vcam’s position and rotation is controlled by the Body and Aim components of that vcam.

Your vcam is using 3rdPersonFollow that means that you need to rotate your Follow target. In your case the gameObject is called LookAt.

Instead of applying your rotation logic to the vcam, apply it to its Follow target.

Note: If LookAt is part of your robot that you do not want to modify, then create an empty gameObject attached to the robot and Follow this instead.

1 Like

Thank you sir!!

1 Like