I have been using the Unity Starter Assets - First Person Character Controller in my project because the one in the tutorial has been deprecated. Just showing my code with the proper adaptations made for it to work with the modern one.
Just need to access the FirstPersonController script on the player capsule, use the StarterAssests namespace, and change the RotationSpeed variable.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Cinemachine;
using StarterAssets;
public class WeaponZoom : MonoBehaviour
{
[SerializeField] public CinemachineVirtualCamera fovCamera;
[SerializeField] float zoomedOutFOV = 60f;
[SerializeField] float zoomedInFOV = 20f;
[SerializeField] float zoomOutSensitivity = 2f;
[SerializeField] float zoomInSensitivity = 1f;
FirstPersonController fpsController;
bool zoomedInToggle = false;
private void Start()
{
fpsController = GetComponent<FirstPersonController>();
}
private void Update()
{
if(Input.GetMouseButtonDown(1))
{
if (zoomedInToggle == false)
{
zoomedInToggle = true;
fovCamera.m_Lens.FieldOfView = zoomedInFOV;
fpsController.RotationSpeed = zoomInSensitivity;
}
else
{
zoomedInToggle = false;
fovCamera.m_Lens.FieldOfView = zoomedOutFOV;
fpsController.RotationSpeed = zoomOutSensitivity;
}
}
}
}