【问题标题】:How to lock the Y-axis for unity's Cinemachine?unity Cinemachine 如何锁定 Y 轴?
【发布时间】:2020-06-25 18:27:18
【问题描述】:

我有一个球,我们可以在我的比赛中到处扔。我希望我的电影机 vcam 只在球的 x 方向上移动。当它在空中时,只需抬头看球。我不希望相机也沿着它在 y 方向上移动。

我只设置了看球和追球场。我只希望相机不跟随 y 中的球。 (基本上就是跟着x方向的球,一直在空中看着它)

我怎样才能实现这是最简单和最美丽的方式? (对脚本开放,但代码越少越好)

【问题讨论】:

    标签: unity3d cinemachine


    【解决方案1】:

    正如我刚刚测试的那样,您可以编写一个附加到您的相机的脚本,您可以在其中使用球的 x 创建一个新的 vector3,并且您想要的冻结 Y 值是一个示例: 公共类 CameraController : MonoBehaviour

    {
        //Assign your ball in the inspector
        public Transform target;
    
        // Update is called once per frame
        void Update()
        {
            //Here i assumed that you want to change the X 
            Vector3 newCamPosition = new Vector3(target.position.x, yourValue, yourValue);
            gameObject.transform.position = newCamPosition;
        }
    }
    

    希望对您有所帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多