I am trying to access to m_CameraDistance of the CinemachineVirtualCamera, but I get the error "NullReferenceException: Object reference not set to an instance of an object" on the last line of the code.
This is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Cinemachine;
public class CameraDistanceController : MonoBehaviour
{
public float _areaCameraDistance = 10;
private float _defaultAreaCameraDistance = 8;
public CinemachineVirtualCamera _vcam;
private CinemachineFramingTransposer _framingTransposer;
void Start()
{
_framingTransposer = _vcam.GetCinemachineComponent<CinemachineFramingTransposer>();
_defaultAreaCameraDistance = _framingTransposer.m_CameraDistance;
}
}
Any ideas? I found another person with the same issue, but there is no answer:
https://quabr.com/69938009/unity3d-cinemachine-how-to-access-camera-distance-in-virtual-camera
Thanks a lot.