- Home /
Duplicate Question
Help making basic health bar script
i am having problems making my health bar its very basic and but im a noob. I wouldn't be surprised if i have done something horrible wrong and blindingly obvious . so here is my code: #pragma strict static var Health : int = 100; var HealthNow = 100; var pos = transform.position; // Use this for initialization function Start () {
}
// Update is called once per frame
function Update () {
if(Health < HealthNow);
{
pos.x + 1;
transform.position = pos;
var HealthNow = Health;
}
}
my error is Assets/health.js(14,20): BCE0034: Expressions in statements must only be executed for their side-effects.
Answer by robertbu · Nov 06, 2014 at 12:59 AM
The error is warning you about the ';' at the end of line 5. It terminates the 'if' so that everything from line 6 to 10 line is executed every frame. Remove the ';' from the end of line 5.
Follow this Question
Related Questions
OnGUI() not showing anything 2 Answers
Health Bar/Hearts? 2 Answers
Having trouble with wheel colliders. (IMMA NEWB) 0 Answers
Script outdated i think, Unity 4 - Compiler errors galore 1 Answer
Very easy mobile controls? 1 Answer