Hi guys!
I’m currently trying to light a spotlight, with the value of a Vector3.Distance. However - I can without ease, return a number into the console (by simply Print(DistanceVector)
, however, when i try to set the light.intensity = DistanceVector;, It’s simply not working!
And also, how would you approach this problem : “The closer you get to the light, the more it lights up”?
I’ve searched around, I just can’t seem to find it!
//Anders Schou
What do you mean ‘Not working’? Does it throw an error? Does it not do anything? Does it do something unexpected?
Ohh! Seems like i had some other script, blocking the function of my first script! Sorry <3
What about the 2nd part of my question? What would YOU guys do, if you were to increase the intensity of a light source, as the player get’s closer to it?
I’d do something like, in psudeocode.
baseValue = 2;
if (distanceFromLight < lightSource.range)
{
intensityDif = lightSource.range - distanceFromLight;
lightSource.intensity = baseValue + intensityDif;
}
I think that it’s possible to do something like that in Unity. I’d experiment with it until I got a solution I was happy with.