hey guys, im making a game and my lives are going 5, 4 ,2, 1, so it skips 3 its strainge please help, here are what is prpbably inportant (btwmy health script is called HealthControl2 :
var health1 : Texture2D; //one live left
var health2 : Texture2D; //two lives left
var health3 : Texture2D; //3 left
var health4 : Texture2D; //4 left
var health5 : Texture2D; //5 left
static var LIVES = 5;
function Update ()
{
switch(LIVES)
{
case 5:
guiTexture.texture = health5;
break;
case 4:
guiTexture.texture = health4;
break;
case 3:
guiTexture.texture = health3;
break;
case 2:
guiTexture.texture = health2;
break;
case 1:
guiTexture.texture = health1;
break;
case 0:
//gameover script here
break;
}
}
and other script part:
function OnTriggerEnter( hit : Collider )
{
if(hit.gameObject.tag == "fallout")
{
dead = true;
//substract life here
HealthControl2.LIVES -= 1;
}
if(hit.gameObject.tag == "enemyProjectile")
{
//gotHit = true;
dead = true;
HealthControl2.LIVES-= 1;
//HealthControl.HITS += 1;
Destroy(hit.gameObject);
}
}
asked
Apr 14 '11 at 10:30 PM
jacques 1
39
●
9
●
13
●
20
This might be a silly question, but are you sure you haven't loaded the same texture to health2 and health3 by a mistake?
Kinda with that, put an if statement for if the lives = 2; print out something to see if it ever does become 2....
textures are in the right place