RE-ASKED
So I am well into a first person shooter, thanks to you guys and all your help, and I wanted to make a level where you are trying to catch a terrorist, but all the house electricity is out. The solution: a flashlight. I want to be able to toggle the flashlight on/off with the ‘f’ key, like in Half Life, Gmod, Transmissions Element 120, etc. Here is the script so far, but I do not know how to do it.
public AudioSource flashlightOn;
public AudioSource flashlightOff;
//audio sources that have the clicking noise for the flashlight
public GameObject flashlight;
void Start () {
}
void Update () {
if (Input.GetButtonDown (KeyCode.F)) {
flashlight.SetActive = true;
flashlightOn.Play ();
} else {
flashlight.SetActive = false;
flashlightOff.Play ();
}
}