Changing Glow Intensity on deltatime

Hey,
when player picks up an object, i want to enable image effect (glow) and fade it out in few seconds. I made the script, it changes intensity (with deltaTime) when picking up, but in game glow stays on. Have any ideas?

Thanks for help :slight_smile:

function Update() {
   if(glow) {
      player.GetComponent("GlowEffect").glowIntensity -= Time.deltaTime;
   }
} 

In component options glow intensity reduces to 0, but in-game it stays on

why not just add:

if(glowIntensity = 0)
{
    player.GetCompnent("GlowEffect").enabled = false;
}

Also, its never good to use a GetComponent (or any kind of lookup) in Update, let’s cache it first:

var glowy : GlowEffect;

function Awake()
{
glow = player.GetComponent("GlowEffect");
}

function Glowiness() // lets also use a co-routine (or helper function, im self
taught, shh :)
{ 
    {
        glowy.glowIntensity -= Time.deltaTime;
    }
if(glow.glowIntensity = 0)
    {
        glow = false;
    }
} 

function Update()
{
    if(glow)// check if we want glow
    {
        Glowiness() //make the magic
    }
}