- Home /
GUI Bloodsplat Screen
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;
}
Answer by Owen-Reynolds · Jun 02, 2013 at 04:03 PM
Internally (in code) all colors and alphas are from 0-1. For example, (1, 0.5, 0) is orange. So change the 126's to 0.5.
thanks, I changed it. However, it's still not working for some reason :S
Ah...the use of Lerp is completely wrong. It isn't a fire&forget, so you can't call it and wait for a second while it does its magic (Lerp is just a single does of boring math.)
Lots of places here to look up how to use a "lerp over time."
Your answer
![](https://koobas.hobune.stream/wayback/20220613103402im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Resolutions 1 Answer
Rendering GUI.Buttons in the middle of the screen 5 Answers
how to get Gui in OnGUI function to resize with the window? 1 Answer
One Last GUI Question 1 Answer
How Do I Center A GUI Label? 5 Answers