You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在脚本中修改Cinemachine相机的Shoulder Offset(肩偏移)

在脚本中修改Cinemachine相机的Shoulder Offset

要在脚本里修改Cinemachine相机的肩偏移(Shoulder Offset),操作步骤如下:

  • 首先引入Cinemachine命名空间,确保能访问相关类:
    using Cinemachine;

  • 获取目标虚拟相机组件以及对应的视角控制组件(以最常用的CinemachineThirdPersonFollow为例,肩偏移是该组件的核心参数):

    // 获取挂载在相机上的虚拟相机组件
    CinemachineVirtualCamera virtualCamera = GetComponent<CinemachineVirtualCamera>();
    // 获取第三人称跟随组件
    CinemachineThirdPersonFollow thirdPersonFollow = virtualCamera.GetCinemachineComponent<CinemachineThirdPersonFollow>();
    
  • 直接修改m_ShoulderOffset属性,设置你需要的偏移值:

    // 示例:设置X轴偏移1,Y轴偏移0.5,Z轴无偏移
    thirdPersonFollow.m_ShoulderOffset = new Vector3(1f, 0.5f, 0f);
    

如果你的虚拟相机使用的是其他Cinemachine组件(比如CinemachineFreeLook),只需要找到对应包含肩偏移参数的组件,用同样的方式获取后修改即可。

内容的提问来源于stack exchange,提问作者runteratroll

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.11 15:05:29