首先创建一个平面plane,然后再创一个胶囊作为人物,给plane加上碰撞体,
给人物加上碰撞体和刚体。
然后创建代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class bj : MonoBehaviour {
public Camera Cam;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButtonDown(1))
{
Cam.fieldOfView = 10;
}
if (Input.GetMouseButtonUp(1))
{
Cam.fieldOfView = 30;
}
}
}
然后把代码托给胶囊
下面为成品