I have entered this code for Health
#pragma strict
var fullHealth = 300 ;
var curHealth = fullHealth;
static var lives = 3 ;
function Start ()
{
print ("Health :" + curHealth) ;
}
function ezzayEsse77a (ozbot : int)
{
if (curHealth >= 1)
{
curHealth = curHealth + ozbot ;
print ("Health" + curHealth) ;
}
else
{
curHealth = 0 ;
kill ();
}
if (curHealth > fullHealth)
{
curHealth = fullHealth ;
}
if (fullHealth < 1 )
{
fullHealth = 1 ;
}
}
function onCollisionEnter (hit : Collision)
{
if (hit.gameObject.tag == "Smallhit")
{
ezzayEsse77a (- 100);
}
else if (hit.gameObject.tag == "Bighit")
{
ezzayEsse77a (- 200);
}
else if (hit.gameObject.tag == "Killerhit")
{
ezzayEsse77a (- 300);
}
else if (hit.gameObject.tag == "up100")
{
ezzayEsse77a (100);
}
else if (hit.gameObject.tag == "up200")
{
ezzayEsse77a (200);
}
else if (hit.gameObject.tag == "up300")
{
ezzayEsse77a (300);
}
}
function kill ()
{
if (lives > 0 )
{
lives -= 1 ;
curHealth = fullHealth ;
}
else
{
lives = 0 ;
}
Debug.Log (lives);
}
and I have tagged the boom with Smallhit
but when the boom touch the car the Health doesn’t change
what is the wrong?