|
heres my script i didnt know what to put for the variable near the end to destroy the enemy when its out of health so i just tried random stuff and found that this combination came up with no errors, except the cube is destroyed at the start of the game, i tried and that just destroyed the enemy 3 seconds after the start of the game help plz.
(comments are locked)
|
|
Hi sam11x, sorry, I'm not sure to have understand your question very well...Do you say that the enemy is destroied at the beginning of the execution? In that case, I think that is wrong. To perform the "Destroy (enemy);" instruction inside the "if" statement you have to delete the ";" at the end of that line. So: Let me know. woohoo thanks
Sep 20 '11 at 08:57 AM
sam32x
Of nothing, sam11x! But thanks @timsk as well...He remarked an important matter, that's the control about the possible-negative health. As he said, in the future, you could create more powerful weapons, that will inflict more than a damage. If the enemy's health will go under 0, he won't die with your actual script.
Sep 20 '11 at 09:14 AM
BiG
(comments are locked)
|
|
The correct usage for an if statement is: such a simple mistake :). Also, i would change "health == 0" to "health <=0". This will solve a future bug that occurs when the enemies health is below 0, which would become a problem if, for example, there was a different bullet that inflicted 5 damage ;).
(comments are locked)
|
|
remove semicolon at the end of - if (health == 0); you should have: function Update(){ if (health == 0) Destroy (enemy); }
(comments are locked)
|
