Hello everyone, this may be the silliest question I’m ever to ask, but if you don’s ask, you don’t know. as title sasy in many scrips I use there seems to be an exclamation mark in them, I don’t quite understand it’s use. I don’t even dare gues in case I’m wrong.
Below, from Turn light on/off - Questions & Answers - Unity Discussions You’ll see a scriot where an exclamation mark is used, and i think I know what it does… but yeah some clarification would be great!
"You can toggle any bool by setting it to the opposite of its current value:
myBool = !myBool;
So you can toggle a light source by toggling its enabled state:
myLight.enabled = !myLight.enabled;
Now you want to do that if you press a certain button:
Light myLight = lightPoint.GetComponent("Light");
if (Input.GetButtonDown("Fire1")) {
myLight.enabled = !myLight.enabled;
}
"