- Home /
Function being called when statement untrue?
The Die() function is being called when the if() statement it is in, is untrue.
function DoDamage () {
if (hitPoints > 0)
hitPoints -= damageAmount;
time = 2.0;
if (hitPoints <= 0)
hitPoints=0;
Die();
}
I don't think you included your entire script - there's nothing in there called 'Die()'. Also, before any attempts to answer your question - have you tried outputting a debug statement to make sure that what you think is false is actually false?
The die function just disables a component, but ins$$anonymous$$d of being called when hitpoints
I got rid of the die function and just placed what it was doing in the if statement, where die was getting called. It is still the same problem.
Answer by bpears · Jan 26, 2013 at 08:03 PM
Oh boy... Forgot my curly braces... Well, I'm embarrassed... hahaha
So what was happening was, since I had no curly braces, the 1st if() statement was the performing of the left overs of the 2nd.
Don't forget you're curly braces people!
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Nested Functions 1 Answer
GUItexture not showing on runtime or trigger 0 Answers
How do I call a function containing a while loop, inside the update function? 2 Answers
Need help with If/else statement. 1 Answer