I have this script (below) as a sort of lifebar for my boss in game.
All is ok but the one problem I have is the part highlighted in bold.
I use this to instantiate 3d text on screen once the boss is defeated.
The problem I have is that the text keeps reproducing, I think this is because it is in the function Update() part of this code but I don’t know how to seperate it from where it is without messing up the script.
If anyone can give me any pointers or help please do! I’m still very new to coding and trying to pick it up by tutorials and trying out things for myself although my knowledge and vocabulary with scripting is rubbish at the moment
var dead : Texture2D; //dead
var lives : Texture2D; //one life left
var lives2 : Texture2D; //2 lives left
var lives3 : Texture2D; //3 lives left
var lives4 : Texture2D; //4 lives left
var Prefabtargetdestroyed_text : GameObject;
var targetdestroyedtext_holder : GameObject;
static var LIVES = 4;
function Update (){
switch(LIVES)
{
case 4:
guiTexture.texture = lives4;
break;
case 3:
guiTexture.texture = lives3;
break;
case 2:
guiTexture.texture = lives2;
break;
case 1:
guiTexture.texture = lives;
break;
case 0:
guiTexture.texture = dead;
**var targetdestroyed_text : GameObject = Instantiate(Prefabtargetdestroyed_text, targetdestroyedtext_holder.transform.position, targetdestroyedtext_holder.transform.rotation);
Prefabtargetdestroyed_text.transform.parent = targetdestroyedtext_holder.transform;**
}
}