- Home /
Question by
Kisanorame · Dec 06, 2012 at 08:31 AM ·
builddamagelifehealth
Damage not triggering in build
Hey guys, I'm using this script for my player's health:
var health=10;
function OnDamage(damage:int)
{
health -= damage;
}
function OnGUI()
{
if(health <- 0)
{
Time.timeScale = 0.0;
if(GUI.Button(Rect(Screen.width/2-100, Screen.height/2-50, 200, 100), "Retry?"))
{
Application.LoadLevel(0);
}
}
}
The script works perfectly when testing in unity itself, but when I build and play it, the timeScale stays at 1.0 and the retry message doesn't display when I take damage.. I've only been using unity a few days, what am I doing wrong?
Comment
Answer by BiG · Dec 06, 2012 at 08:33 AM
This line
if(health <- 0)
has a wrong synthax, and it should be:
if(health <= 0)
I wonder how it can be compiled and works perfectly :-)
However, I hope that's the only problem, and that you can get it work, now.
Your answer
Follow this Question
Related Questions
Damage script is messed up, how to fix 1 Answer
How to create/fix fire damage script???? 1 Answer
Damage script is screwed up...? what to do? 1 Answer
Player Health Not Working? 4 Answers
Player won't take damage... 1 Answer