Hey all,
I played with the following script to use a key in order to change the camera view between the main camera and a secondary camera (like first person and third person views). I achieve it with that script and all works as it should:
public cam1 : Camera;
public cam2 : Camera;
public KeyCode CameraKey;
function Start() {
cam1.enabled = true;
cam2.enabled = false;
}
function Update() {
if (Input.GetKeyDown(CameraKey)) {
cam1.enabled = !cam1.enabled;
cam2.enabled = !cam2.enabled;
}
}
BUT I would love to understand what this “xxx.enabled = !xxx.enabled;” does. How to understand this kind of function. Sadly I don’t know what keyword to google here, when you try to google “! =” in combination with “C#” nothing useful comes up…
So my question is how does this logically work? Is there a name for this kind of “toggle-function”?
Thanks in advance