Simple Light Script causing problems

I’m having trouble getting my light script to work. It’s very simple, all it does is find the light attached to the object and then changes the spotAngle to a predetermined size.

////////////This Script goes on the "MoveRangeIdentifier"

var TheLight;

var BoundingScale : int;


function Update () {

TheLight = transform.Find("MoveRangeLight").light;

if(TheActivePlayerSwitch == true){

TheLight.intensity = 8;
TheLight.spotAngle = BoundingScale;

}
}

Now it may be worth mentioning that the light type is a Directional with a hard-edged cookie attached to it. From what I read, the spotAngle on a directional light is supposed to adjust the size of the cookie.

the adjustment of the intensity works fine, but the spotAngle adjustment doesn’t work at all no matter what I try. I imagine that I’m calling it in the wrong way

If anyone can provide some insight, it’d be greatly appreciated!

This appears to be a mistake in the docs (or possibly a bug) - I have created a bug database entry for it. Note that you can change a directional light’s cookie using the Cookie Size property in the inspector but this is not exposed in the API.

Kay thanks Andeeee, that’s a shame though :-S. Was perfect for what I needed

If Anyone else knows of some trick to making this work, please let me know.

On the offchance that someone one day finds this post while looking for a solution to the same problem, I got around the issue by just making multiple lights of the pre-designated size that I required. For my particular needs they are in increments of 3, (one with a cookie size of 9, one with a cookie size of 12, then 15, etc.) And I just swap them out using a simple script. Hope it helps, but moreso, hope that this bug gets fixed in the future. Unity still rocks though