Ok what I am asking for is fairly simple however it is giving me problems. I have also seen similar questions asked but none of the suggestions have worked for me. I am trying to create a shock wave that expands outwards then fades away programaticaly. I am using this code:
var Dammage : float = 1; //How much dammage the projectile does on impact;
var Speed : float = 1; //How fast does the projectile move
var Lifetime : float = 10; //How long does the projectile last
private var TimePassed : float = 0;
function Update ()
{
transform.localScale += Vector3(Speed,Speed,Speed);
TimePassed += Time.deltaTime;
if(TimePassed >= Lifetime / 2)
{
//Fade Material
renderer.material.color.a = 1 - 1 * TimePassed / Lifetime;
Debug.Log("Should fade");
}
if(TimePassed >= Lifetime)
{
Destroy(gameObject);
}
}
This does not throw up any errors in the compiler nor at run-time, however it also has no effect. The material I am using is a “Unlit/Transparent” so it does have an alpha channel. However, it does also have a texture assigned to it that has its own alpha settings. Is there something special I need to do to get a material to fade out when it has a texture, or am I just doing something wrong?
Thanks in advance for the help : )