C# 我怎样才能使相机的轨道也向上和向下?

C# 我怎样才能使相机的轨道也向上和向下?,c#,unity3d,C#,Unity3d,我应该使用Cinemachine吗?还是最好从头开始用脚本 脚本将附加到主摄影机 现在它的轨道只有左-右。我想让它在夹钳的作用下360度旋转,这样它就不会向下移动到地板上,也不会向后移动 我也应该是Y,而不仅仅是X,但不确定如何 using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerFollow : MonoBehaviour { public

我应该使用Cinemachine吗?还是最好从头开始用脚本

脚本将附加到主摄影机

现在它的轨道只有左-右。我想让它在夹钳的作用下360度旋转,这样它就不会向下移动到地板上,也不会向后移动

我也应该是Y,而不仅仅是X,但不确定如何

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerFollow : MonoBehaviour {

    public Transform PlayerTransform;

    private Vector3 _cameraOffset;

    [Range(0.01f, 1.0f)]
    public float SmoothFactor = 0.5f;

    public bool LookAtPlayer = false;

    public bool RotateAroundPlayer = true;

    public float RotationsSpeed = 5.0f;

    // Use this for initialization
    void Start () {
        _cameraOffset = transform.position - PlayerTransform.position;  
    }
    
    // LateUpdate is called after Update methods
    void LateUpdate () {

        if(RotateAroundPlayer)
        {
            Quaternion camTurnAngle =
                Quaternion.AngleAxis(Input.GetAxis("Mouse X") * RotationsSpeed, Vector3.up);

            _cameraOffset = camTurnAngle * _cameraOffset;
        }

        Vector3 newPos = PlayerTransform.position + _cameraOffset;

        transform.position = Vector3.Slerp(transform.position, newPos, SmoothFactor);

        if (LookAtPlayer || RotateAroundPlayer)
            transform.LookAt(PlayerTransform);
    }
}