So, im using this code by RoxSilverFox
//blood splat HUD element
var fadeDuration:float=0.5;
var initialDelay:float=5;
private var timeLeft:float=0.5;
FPSPlayer.hitPoints = 100;
function Awake () {
timeLeft = fadeDuration;
}
function Update () {
if (initialDelay > 0){
initialDelay = initialDelay-Time.deltaTime;
} else {
if (FPSPlayer.hitPoints < 25.0)
fade(true);
else {
if (FPSPlayer.hitPoints > 25.0)
fade(false);
}
}
}
function fade(direction:boolean){
var alpha;
if (direction){
if (guiTexture.color.a < 0.5){
timeLeft = timeLeft - Time.deltaTime;
alpha = (timeLeft/fadeDuration);
guiTexture.color.a=0.5-(alpha/2);
} else {
timeLeft = fadeDuration;
}
} else {
if (guiTexture.color.a > 0){
timeLeft = timeLeft - Time.deltaTime;
alpha = (timeLeft/fadeDuration);
guiTexture.color.a=alpha/2;
} else {
timeLeft = fadeDuration;
}
}
}
Is it possible to make this work for any resolution?
Like instead of using a GUItexture with this, attach this script to the player and make it draw a texture that can be edited to fit any screen?
The problem is, i dont know how to do the fading part. The one in that code dosnt work with a variable type "texture"m only seems to work with GUItexture.
BTW, this as it is shows the texture below my GUI. Which is what i want, but when i try to use draw texture it draws it above everything.