- Home /
Question by
DaHare · Dec 07, 2014 at 10:59 PM ·
c#functionmonodevelophealth
My die function gets called without me asking it.
I am pretty new to unity and i cant get this to work. I have a problem with my Script i have a Die function that gets called without a reason i can see? and i have not even put damage in the script either. please help me! this is my script made in c#.
using UnityEngine; using System.Collections;
public class Health : MonoBehaviour {
int PlayerHealth = 100;
void Update ()
{
if (PlayerHealth <= 0);
{
Die();
}
}
void Die ()
{
print ("WTF!!");
}
}
Comment
Answer by MrSoad · Dec 07, 2014 at 11:07 PM
You have an ; at the end of the if statement, this should not be there :
if (PlayerHealth <= 0);
should be :
if (PlayerHealth <= 0)