I have a Bloodsplat gameobject /GUITexture/. And I want it to appear, and quickly disappear with fading out the alpha when applying damage. What’s wrong with my script?
var BloodSplat : GameObject;
var FadingTime : float = 1.5;
function Start () {
BloodSplat.SetActiveRecursively(false);
BloodSplat.guiTexture.color.a = 126;
}
function ApplyDamage (Damage : float){
BloodSplat.SetActiveRecursively(true);
BloodSplat.guiTexture.color.a = Mathf.Lerp(126, 0, FadingTime);
yield WaitForSeconds(FadingTime);
BloodSplat.SetActiveRecursively(false);
BloodSplat.guiTexture.color.a = 126;
}