【问题标题】:How to access the Tracked Object Offset in the Body of CinemachineVirtualCamera?如何访问 CinemachineVirtualCamera 主体中的被跟踪对象偏移量?
【发布时间】:2021-10-07 10:34:26
【问题描述】:

我是 Unity Cinemachine 的新手,我正在尝试使用代码更改 CinemachineVirtualCamera 主体中 Tracked Object Offset 的 y 值。

我阅读了一些关于更改值的文章,而我目前的代码是

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

然后我收到NullReferenceException: Object reference not set to an instance of an object 的错误消息,当我打印出cinemachineOffset 的值时,我得到空值,所以我认为我做得不对。所以我想知道如何访问 Body 的 CinemachineVirtualCamera 的 Y 值...

【问题讨论】:

  • CinemachineCam 的检查器中是否设置了“目标对象”属性?

标签: c# unity3d camera cinemachine


【解决方案1】:

您需要访问您的框架转置器对象,例如:

yourCamera.GetComponentInChildren<CinemachineFramingTransposer>()

然后您就可以访问框架转置器拥有的任何变量。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-04-21
    • 2020-09-06
    • 1970-01-01
    • 1970-01-01
    • 2021-08-05
    • 1970-01-01
    • 2013-02-15
    相关资源
    最近更新 更多