I’ve spent a good while looking for what I’m doing wrong and I think it’s officially time to admit I need help.
I wanted to have a light source that dies off over time by shrinking its range over time. Here’s what I have:
var increment : float = 1.00;
function update () {
light.range = light.range - (increment * Time.deltaTime);
}
I’d also like to eventually make it so that the declared variable is time in seconds and also declare its initial range, but I’ll cross that bridge when I get there.
If your range is quite large, like 100 or something, it’s probably just decreasing really really slowly. Keep in mind that delta time is the time in seconds since the last frame, so it’s going to be a very small number. Just increase increment to something like 20 and it should start working.
If not, it’s probably because you don’t have a point light on the same object as the script.
No, I have it attached to a point light and I’m looking at the range in the inspector window. Also I cranked up the increment to 1000 and there was no change. I also just put this in:
var increment : float = 1.00;
function update () {
light.range = 0;
}