Hello! I am trying to create an FPS game. I have made a flashlight that works with the press of a button to turn it on and off. My only problem is that I don’t want the flashlight to be turned on when I start the playmode. I want it to be turned off by default.
I tried boolean = false ; but it just said the “boolean is not assigned to”.
I am pretty new to Unity. Can anyone help?
Heres my script :
private var flashlight : Light;
function Start () {
flashlight = GetComponent("Light");
}
function Update () {
if (Input.GetKeyDown("g")) {
if (flashlight.enabled) {
flashlight.enabled = false;
} else {
flashlight.enabled = true;
}
}
}