版权声明:本博客所上传的任意博客都归本人所有,本人拥有最终解释权 https://blog.csdn.net/qq_34199256/article/details/80443559
[SerializeField]
private Camera mainCamera, thirdPersonCamera;
bool firstPersonViewOrThirdPersonView = false;
//false为主相机深度更大 , true为第三人称相机深度更大
void Update()
{
if (Input.GetKeyDown(KeyCode.V))
{
if (firstPersonViewOrThirdPersonView == false)
firstPersonViewOrThirdPersonView = true;
else
firstPersonViewOrThirdPersonView = false;
}
if (firstPersonViewOrThirdPersonView == true)
{
thirdPersonCamera.depth = 1;
mainCamera.depth = 0;
}
if (firstPersonViewOrThirdPersonView == false)
{
mainCamera.depth = 1;
thirdPersonCamera.depth = 0;
}
private Camera mainCamera, thirdPersonCamera;
bool firstPersonViewOrThirdPersonView = false;
//false为主相机深度更大 , true为第三人称相机深度更大
void Update()
{
if (Input.GetKeyDown(KeyCode.V))
{
if (firstPersonViewOrThirdPersonView == false)
firstPersonViewOrThirdPersonView = true;
else
firstPersonViewOrThirdPersonView = false;
}
if (firstPersonViewOrThirdPersonView == true)
{
thirdPersonCamera.depth = 1;
mainCamera.depth = 0;
}
if (firstPersonViewOrThirdPersonView == false)
{
mainCamera.depth = 1;
thirdPersonCamera.depth = 0;
}
}
if (Input.GetKey(KeyCode.W))
cc.Move(transform.forward * 7 * Time.deltaTime);
if (Input.GetKey(KeyCode.S))
cc.Move(transform.forward * -7 * Time.deltaTime);
if (Input.GetKey(KeyCode.A))
transform.Rotate(Vector3.up * -3);
if (Input.GetKey(KeyCode.D))
transform.Rotate(Vector3.up * 3);
if (Input.GetKey(KeyCode.LeftShift))
cc.Move(transform.forward * 9 * Time.deltaTime);