- Home /
lighting script help
i have made this script and it doesnt work. what i was trying was mouse DOWN light ON and mouse UP light off
var islighton = 0;
function Update() {
if (islighton == 0 && Input.GetKeyDown ("Fire1")) {
light.intensity = 1;
}
else if (islighton == 1 && Input.GetKeydown("Fire1")) {
light.intensity = 0;
}
}
if someone can show me where i went wrong and amend it that would be great
thanks everyone
Comment
Best Answer
Answer by tanoshimi · Sep 08, 2014 at 03:03 PM
Use Input.GetMouseButtonDown(0)
, not Input.GetKeyDown
(and definitely not Input.GetKeydown
).
You don't need the islighton
variable at all.
function Update() {
if (Input.GetMouseButtonDown(0)) {
light.intensity = 1;
}
else if (Input.GetMouseButtonUp(0)) {
light.intensity = 0;
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613162559im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
hide child object script - help 1 Answer
button question 1 Answer
Need Help with rebuildable barricade system like in Call Of Duty Zombies 1 Answer
Help Solve This 2 Answers