x


skipping lives!

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);
         }
    }
more ▼

asked Apr 14 '11 at 10:30 PM

jacques 1 gravatar image

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?

Apr 14 '11 at 11:07 PM Wibbs 1

Kinda with that, put an if statement for if the lives = 2; print out something to see if it ever does become 2....

Apr 15 '11 at 01:37 AM Justin Warner

textures are in the right place

Apr 17 '11 at 08:12 PM jacques 1
(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x27
x11

asked: Apr 14 '11 at 10:30 PM

Seen: 320 times

Last Updated: Apr 14 '11 at 11:27 PM