- Home /
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 :)
function Update() {
if(glow) {
player.GetComponent("GlowEffect").glowIntensity -= Time.deltaTime;
}
}
In component options glow intensity reduces to 0, but in-game it stays on
You ought to post your code so we can see what is wrong
Answer by timsk · Oct 17, 2011 at 03:33 PM
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
}
}
wait... is GlowEffect a type? I've never used unity pro :D
If you get an error on the first line, delete " : GlowEffect" so this should just leave "var glowy;"
Your answer
Follow this Question
Related Questions
Importing Grey scale Image In Unity, The Best Practice ? 0 Answers
[4.6 UI] Image fading - How to? 2 Answers
Toggle image effects 2 Answers
Fade GUITexture 1 Answer
Add smooth parts to UI.Image 1 Answer