hi guys i have a health control script thats have some problem,when i play the game its working fine by minus 1 lives but when i replay the game its minus 3 lives or even 6 lives.
i do not know why i suspect is because i have 2 different damage style that make the health control script crash, one is fallout the other one is bullet.
here my health control script:
var health3 : Texture2D;
var health2 : Texture2D;
var health1 : Texture2D;
var player : Transform;
static var Lives = 3;
private var playerInfo : ThirdPersonStatus;
// Cache link to player's state management script for later use.
function Awake()
{
playerInfo = FindObjectOfType(ThirdPersonStatus);
if (!playerInfo)
Debug.Log("No link to player's state manager.");
}
function Update()
{
print("Lives: "+Lives+" Hits: "+HITS);
switch(Lives)
{
case 3:
guiTexture.texture = health3;
break;
case 2:
guiTexture.texture = health2;
break;
case 1:
guiTexture.texture = health1;
break;
case 0:
Application.LoadLevel("3");
break;
}
and here my thirpersonststus:
function LateUpdate()
{
if(dead)
{
transform.position = Vector3(639,39,427);
gameObject.Find("Main Camera").transform.position = Vector3(639,39,-427);
dead = false;
}
}
function OnControllerColliderHit(hit : ControllerColliderHit)
{
if(hit.gameObject.tag == "fallout")
{
dead = true;
HealthControl.Lives -= 1;
}
else if(hit.gameObject.tag == "bomgy 1")
{
dead = true;
HealthControl.Lives -= 1;
}
if(hit.gameObject.tag == "spike")
{
dead = true;
HealthControl.Lives -=1;
}
}
please fix your code formatting, there is a code block button ( icon is 0s and 1s )
– anon19958801