“幽灵视角”,适合用来漫游场景
把代码加载到摄像机上
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Control : MonoBehaviour {
public float zoomSensitivity = 10f;
public float mouseSensitivity = 5f;
public float speedSensitivity = 20f;
private float m_deltX = 0f;
private float m_deltY = 0f;
private Camera mainCamera;
void Start () {
mainCamera = GetComponent<Camera>();
m_deltX = mainCamera.transform.rotation.eulerAngles.x;
m_deltY = mainCamera.transform.rotation.eulerAngles.y;
}
// Update is called once per frame
void Update ()
{
if (Input.GetMouseButton(0))
{
LockCursor(true);
UFOMove();
ZoomMove();
}
else LockCursor(false);
}
private void FixedUpdate()
{
if (Input.GetMouseButton(0))