using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class cameraSwitch : MonoBehaviour
{
public GameObject P1;
public GameObject P3;
private bool camerastatus = true;
// Start is called before the first frame update
void Start()
{
P1.SetActive(false);
P3.SetActive(true);
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyUp(KeyCode.O))
{
if (camerastatus == true)
{
P1.SetActive(false);
P3.SetActive(true);
camerastatus = false;
}
else
{
P1.SetActive(true);
P3.SetActive(false);
camerastatus = true;
}
}
}
}
第一人称摄像头放置在主角的前面
第三人称摄像头放置在主角的背后
设置好第一、第三人称的摄像头,拖进脚本界面,指定对象,按0键就可以切换了



