public class PlayerShootController : NetworkedBehaviour
{
[SerializeField] private CinemachineVirtualCamera aimCamera;
[SerializeField] private CinemachineVirtualCamera followCamera;
[SerializeField] private float normalSensitivity = 1f;
[SerializeField] private float aimSensitivity = 0.5f;
[SerializeField] private LayerMask aimColliderLayerMask;
private StarterAssetsInputs _inputs;
private ThirdPersonController _thirdPersonController;
private void Awake()
{
_inputs = GetComponent<StarterAssetsInputs>();
}
private void Update()
{
if (IsLocalPlayer)
{
if (_inputs.aim)
{
followCamera.gameObject.SetActive(false);
aimCamera.gameObject.SetActive(true);
_thirdPersonController.SetSensitivity(aimSensitivity); // Error here
}
else
{
followCamera.gameObject.SetActive(true);
aimCamera.gameObject.SetActive(false);
_thirdPersonController.SetSensitivity(normalSensitivity); // Error here
}
Vector2 screenCenter = new Vector2(Screen.width / 2f, Screen.height / 2f);
Ray ray = Camera.main.ScreenPointToRay(screenCenter);
if (Physics.Raycast(ray, out RaycastHit raycastHit, 999f, aimColliderLayerMask))
{
}
}
}
}
ThirdPersonController.cs
public float Sensitivity = 1f;
public void SetSensitivity(float newSensitivity)
{
Sensitivity = newSensitivity;
}
private void CameraRotation()
{
// if there is an input and camera position is not fixed
if (_input.look.sqrMagnitude >= _threshold && !LockCameraPosition)
{
//Don't multiply mouse input by Time.deltaTime;
float deltaTimeMultiplier = IsCurrentDeviceMouse ? 1.0f : Time.deltaTime;
_cinemachineTargetYaw += _input.look.x * deltaTimeMultiplier * Sensitivity; // it is used here
_cinemachineTargetPitch += _input.look.y * deltaTimeMultiplier * Sensitivity;
}
// clamp our rotations so our values are limited 360 degrees
_cinemachineTargetYaw = ClampAngle(_cinemachineTargetYaw, float.MinValue, float.MaxValue);
_cinemachineTargetPitch = ClampAngle(_cinemachineTargetPitch, BottomClamp, TopClamp);
// Cinemachine will follow this target
CinemachineCameraTarget.transform.rotation = Quaternion.Euler(_cinemachineTargetPitch + CameraAngleOverride, _cinemachineTargetYaw, 0.0f);
}
It was working for a while, but then i changed something in the code in other class, complied it and this wild error happend. Am I blind or missing something?