- Home /
(Resolved) Help on creating a Camera Flash (script provided)
Alright guys, still learning my way around scripting. For this, all I need is when the left mouse button is clicked, a quick flash of a light (from a spotlight attached to the players head) would be initiate.
var Flash : Light;
var FlashLength = 0.1;
var maxScale = 0.25;
function Update ()
{
if (Input.GetMouseButtonDown("0"))
{
LightFlashes();
}
}
function LightFlashes()
{
Flash.active = true;
yield WaitForSeconds(FlashLength);
Flash.active = false;
}
I am getting this error message "Assets/Standard Assets/Scripting/FlashOfLight.js(8,33): BCE0017: The best overload for the method 'UnityEngine.Input.GetMouseButtonDown(int)' is not compatible with the argument list '(String)'."
Answer by rutter · May 23, 2014 at 10:48 PM
This bit:
Input.GetMouseButtonDown("0")
Needs to be:
Input.GetMouseButtonDown(0)
Notice the quotes. Some languages allow you to easily switch between numbers and strings, but others do not. You might check around for any handy tutorials about the difference between an int
and a string
.
That was it rutter, thanks so much for that. I had no idea what "int" and "string" is.
Thanks again!
Your answer
Follow this Question
Related Questions
Cannot Get Light To Flash - Help 1 Answer
Does anyone know of some good scripting tutorials? 2 Answers
Why isn't my flashing script working? 1 Answer
How do I animate a pulsing light? 1 Answer
Lights cancel each other out 1 Answer