通过按住右键滑动调整视角
public class Rotate : MonoBehaviour
{
public float rotateSpeed = 100;
public Transform PlayerTrans;
public float maxh = 10;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if(Input.GetMouseButton(1))
{
float nor = Input.GetAxis("Mouse X");
float hor = Input.GetAxis("Mouse Y");
PlayerTrans.RotateAround(PlayerTrans.position, Vector3.up, Time.deltaTime * rotateSpeed * nor);
PlayerTrans.RotateAround(PlayerTrans.position, Vector3.left, Time.deltaTime * rotateSpeed * hor);
}
}
}
把主摄像机拖拽到PlayerTrans上即可