- Home /
health problem
hi I have a problem with a health script (it's not mine but I have changed some things
var curHealth : int = 100;
var maxHealth : int = 100;
var healthtext : GUIText;
function Start ()
{
healthRegen();
}
function OnControllerColliderHit(hit : ControllerColliderHit){
if (hit.gameObject.CompareTag("movingwall")){
curHealth = curHealth - 10;
}
}
function Update ()
{
healthtext.text = curHealth + " / " + maxHealth;
if(curHealth < 0 )
{
curHealth = 0;
}
if(curHealth > 100)
{
curHealth = 100;
}
if(curHealth <= 0)
{
Application.LoadLevel(Application.loadedLevel);
}
}
function healthRegen ()
{
for(i=1;i>0;i++)
{
yield WaitForSeconds(0.5);
if(curHealth < maxHealth)
{
curHealth++;
}
}
}
everything looks good but when i start my game and i walk against te movingwall nothing happens sorry for my bad english but i'm not english i hope that one of u can help me
Comment
for(i=1;i>0;i++)
What's this supposed to do? Did you make an endless loop on purpose? Why not use while(true) if so?
Best Answer
Answer by TCD · Jun 28, 2014 at 03:05 PM
Do you have a Collider on the wall that is not Trigger?
Your answer
Follow this Question
Related Questions
Health C# script problem. 3 Answers
Make the first person controller transparent? 1 Answer
Problem with health bar 1 Answer
Increase health smoothly not instantly? 2 Answers
A node in a childnode? 1 Answer