1

I'm new to Unity Cinemachine and I'm trying to change the y value of the Tracked Object Offset in the Body of CinemachineVirtualCamera using code. enter image description here

I read some articles for changing the value and what I currently have on my code is

private CinemachineCameraOffset cinemachineOffset;
Void Start() {
    cinemachineOffset.m_Offset = this.transform.localToWorldMatrix * new Vector3(0, 20, 0);
}

Then I get the error message saying NullReferenceException: Object reference not set to an instance of an object, and when I print out the value of cinemachineOffset, I get null, so I think I'm not doing right. So I was wondering how I can access the Y value of the CinemachineVirtualCamera of the Body...

Yuuu
  • 715
  • 1
  • 9
  • 32

1 Answers1

0

You need to get access to your framing transposer object like:

yourCamera.GetComponentInChildren<CinemachineFramingTransposer>()

and then you have access to any variable that your framing transposer has.