- Home /
Question by
ninjaboynaru · Jul 06, 2012 at 07:42 PM ·
lightrange
Light Script that increses brightness when button pressed then shuts off
I would like a Java script for a light that increases the brightness/range per second of a light when the space button is pressed, then once the light reaches a certain brightness/range it is shut off, or destroyed or the brightness starts to decrease
Comment
Best Answer
Answer by thurone · Jul 07, 2012 at 12:57 AM
You'll have to use the range and intensity attributes of the light. You could do something like:
function Update()
{
if(Input.GetButtonDown("Jump")){
{
if(increaseEnabled)
{
myLight.intensity+=1;
var increaseEnabled=false
EnableIncrease();
}
}
}
private function EnableIncrease()
{
WaitForSeconds(1);
increaseEnabled=true;
}
Of course this could use some finetuning and declaring the variables but this should explain the idea.
Your answer
Follow this Question
Related Questions
AI Range indicator 1 Answer
How to make a dirt effect 0 Answers
See whether player is in range of light 2 Answers
Flashlight battery script 3 Answers
Error BCE0077 1 Answer