Dong_Minh_Doxygen: D:/Google Drive/Unity Projects/Tank Game/Assets/Scripts/CameraSwitch.cs Source File

Dong Minh

Dong_Minh_Doxygen
CameraSwitch.cs
Go to the documentation of this file.
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4 
5 public class CameraSwitch : MonoBehaviour {
6 
7  public Camera thirdPCamera;
8  public Camera overheadCamera;
9 
10  private bool switchCam = false;
11 
22  void Start () {
23 
24  thirdPCamera.GetComponent<Camera> ().enabled = true;
25  overheadCamera.GetComponent<Camera> ().enabled = false;
26  }
27 
45  void Update () {
46 
47  // get the input key
48  if (Input.GetKeyDown ("f")) {
49  switchCam = !switchCam;
50  }
51 
52  // check if the switch camera happened
53  if (switchCam == true) {
54 
55  thirdPCamera.GetComponent<Camera> ().enabled = false;
56  overheadCamera.GetComponent<Camera> ().enabled = true;
57  }
58  else {
59  thirdPCamera.GetComponent<Camera> ().enabled = true;
60  overheadCamera.GetComponent<Camera> ().enabled = false;
61  }
62  }
63 }
Camera overheadCamera
Definition: CameraSwitch.cs:8
Camera thirdPCamera
Definition: CameraSwitch.cs:7
void Start()
This is to intialize upon start of the game
Definition: CameraSwitch.cs:22
void Update()
This will update every fame to check whether the user switch cams or not.
Definition: CameraSwitch.cs:45
Generated by   doxygen 1.8.13