[18500-need+to+get+help+.png|18500]
3 Answers
3I believe what you have done is forgotten to use an if statement. You also forgot to close your Start function, which you really don’t need here at all. Here’s a revised version of your code. This should work:
var hp:float;
function Update()
{
if(hp <= 0)
{
Destroy(gameObject);
}
}
I think before you start scripting stuff you should learn how to code in Unity. No offense…
You have a javascript file. The syntax for pragma strict for javascript can be found here: What exactly is a JavaScript pragma? - Stack Overflow
Yeh but this is a school class project. And I dont have time to learn.
That should have been a comment. And a fine funny one too. School project with no time to learn. LOL.
– DaveA
Remember to initialize hp to something greater than zero, or the object will die right after its birth (uninitialized variables start with value 0): var hp: float = 100;
– aldonaletto