- Home /
script for flashlight is preventing game from working?
wondering if i did this right: function Update () {
if (Input.GetKeyDown(f)) { if (light.enabled == true) light.enabled = false; else
light.enabled = true;
}
}
Answer by T27M · Nov 27, 2012 at 12:53 AM
I'm assuming the light isn't turning on or off? Try this:
function Update ()
{
if (Input.GetKeyDown(KeyCode.F) && light.enabled == true )
{
light.enabled = false;
}
else if ( Input.GetKeyDown(KeyCode.F) && light.enabled == false )
{
light.enabled = true;
}
}
even with that script there are errors:/ i need to find one that doesnt have compiler errors!!
Woops i missed a semicolon. It also helps if you read what the error is. Code updated.
i had already inserted the semicolon, but the error message keeps saying that its expecting ) ins$$anonymous$$d of ( for (5,27)
It would help if you edit your question and post your whole script. Does it compile without my code? Did it compile with your code before? Was there another problem( error message )?
Edit: Updated Again.
i edited my question, and that was my WHOLE script for flashlight (im using a spotlight connected to my fps's head. got the script from some guy on youtube, have any sugestions for how i can get a working script that will allow me to toggle the flashlights beam?
Your answer
Follow this Question
Related Questions
How do I use a toolbar? 1 Answer
compiler errors with the fps tutorial 0 Answers
Custom Build step before compilation 1 Answer
Errors are appearing but i don't know how to fix these... 1 Answer