1

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

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

我怎样才能做到这一点是最琐碎和美丽的方式呢?(对脚本开放,但代码越少越好)

4

1 回答 1

0

正如我刚刚测试过的那样,您可以编写一个附加到您的相机的脚本,您可以在其中使用球的 x 创建一个新的 vector3,并且您想要的冻结 Y 值是一个示例: public class 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;
    }
}

希望它有所帮助<3

于 2020-06-25T22:38:12.833 回答