I have been looking for a script to slowly decrease the health of a player. (e.g when in a fire environment)
I currently have a basic script that will display the health bar, can anyone help me create a script to gradually reduce the players health?
var health100 : Texture2D;
var health95 : Texture2D;
var health90 : Texture2D;
var health85 : Texture2D;
var health80 : Texture2D;
var health75 : Texture2D;
var health70 : Texture2D;
var health65 : Texture2D;
var health60 : Texture2D;
var health55 : Texture2D;
var health50 : Texture2D;
var health45 : Texture2D;
var health40 : Texture2D;
var health35 : Texture2D;
var health30 : Texture2D;
var health25 : Texture2D;
var health20 : Texture2D;
var health15 : Texture2D;
var health10 : Texture2D;
var health5 : Texture2D;
var health0 : Texture2D;
var LIVES = 21;
function Update ()
{
switch(LIVES)
{
case 21:
guiTexture.texture = health100;
break;
case 20:
guiTexture.texture = health95;
break;
case 19:
guiTexture.texture = health90;
break;
case 18:
guiTexture.texture = health85;
break;
case 17:
guiTexture.texture = health80;
break;
case 16:
guiTexture.texture = health75;
break;
case 15:
guiTexture.texture = health70;
break;
case 14:
guiTexture.texture = health65;
break;
case 13:
guiTexture.texture = health60;
break;
case 12:
guiTexture.texture = health55;
break;
case 11:
guiTexture.texture = health50;
break;
case 10:
guiTexture.texture = health45;
break;
case 9:
guiTexture.texture = health40;
break;
case 8:
guiTexture.texture = health35;
break;
case 7:
guiTexture.texture = health30;
break;
case 6:
guiTexture.texture = health25;
break;
case 5:
guiTexture.texture = health20;
break;
case 4:
guiTexture.texture = health15;
break;
case 3:
guiTexture.texture = health10;
break;
case 2:
guiTexture.texture = health5;
break;
case 1:
//gameover script here
break;
}
}
EDIT***
After looking around some more I have come across a thread that seems relevant to what I want. But the problem Im having is combining the first script with the new one?