Imagine your chair slowly turning green as the light bulb above you is dimming…
All I need is the link between the two.
What I have so far…
var target : GameObject;
function DrainBattery()
{
Charge = Mathf.Clamp(Charge - Time.deltaTime, 0, MaxCharge);
} function UpdateLight()
{
lightToDim.intensity = Mathf.Lerp(LightOff, LightOn, Charge / MaxCharge);
}
So I’m guessing your light is dimming correctly? You just want to change the colour of your target with the same speed as your dim?
To access the colour of a game object, you simply use:
target.renderer.material.color
With that in mind:
var target : GameObject;
var newColor : Color;
funciton Start(){
//Only want the colour to be Green
newColor.r = 0;
newColor.b = 0;
}
function DrainBattery(){
Charge = Mathf.Clamp(Charge - Time.deltaTime, 0, MaxCharge);
}
function UpdateLight(){
lightToDim.intensity = Mathf.Lerp(LightOff, LightOn, Charge / MaxCharge);
//Apply the same lerp to the colour
newColor.g = Mathf.Lerp(LightOff, LightOn, Charge / MaxCharge);
target.renderer.material.color = newColor;
}