I would like to fade out a GameObject and all its children. I tryed that script, attached to the parent Object which i found here in the forum. it works, but the result is a fade in and a fade out. (it might be the Mathf.PingPong but i dont know.)
how can the script be changed to a simple fadeout?
Thank you!
var duration = 1.0;
function Update () {
var lerp = Mathf.PingPong(Time.time, duration) / duration;
var renderers = gameObject.GetComponentsInChildren (Renderer);
for (var rend : Renderer in renderers) {
rend.renderer.material.color.a = Mathf.Lerp (0.6, 0.0, lerp);
}
}