How to fade out picture

@karlkevin

I am making a “instructions picture”, where picture should fade out after starting the scene, atm i have made this

using UnityEngine;
using System.Collections;

public class Fade : MonoBehaviour {
float duration = 2;

void Update() {
	if (Time.time > duration) {
		Destroy (gameObject);
	}


}

}

and as you can see, it just destroys itself after 2 seconds, but I want to fade it, for example over 1 second. And if you know how to even make it like in flappy bird used to have, that after touching the screen, it fades out, not after 2 seconds. I hope you undrestand what I mean and I hope you can help me with this simple problem. Thank you for helping! :slight_smile:

Hi @karlkevin ,

Try this,

float fadePerSec = 1.5f;

 private void Update() {
     var material = GetComponent<Renderer>().material;
     var color = material.color;
     material.color = new Color(color.r, color.g, color.b, color.a - (fadePerSec * Time.deltaTime));
 }