Hi. Im trying to achieve a fading affect. But my object fades instantly.
var object1 : GameObject;
var Fad : float;
var Changed : boolean;
function Start () {
}
function Update () {
GetComponent(SpriteRenderer).color.a = Fad;
if(object1.transform.position.x > -2.3 && Changed == false) {
Fad = Mathf.Lerp(0.0, 1.0, 5);
Changed = true;
}
}
I want to make that my game object would smoothly fade in 5 seconds, but Fad changes to 1 instantly.