I was wondering if anyone could tell me why this doesn’t work, seems like it should. I am new to scripting in Java Script though
void OnTriggerEnter (Collider col)
{
if (healthAmount = 0.0f);
Destroy(GameObject) = true
}
I was wondering if anyone could tell me why this doesn’t work, seems like it should. I am new to scripting in Java Script though
void OnTriggerEnter (Collider col)
{
if (healthAmount = 0.0f);
Destroy(GameObject) = true
}
Line 3: get rid of the semicolon, and change the = to === (or ==, if Unity’s implementation doesn’t recognize ===)
Line 4: change to Destroy(gameObject);
Code:
void OnTriggerEnter (col : Collider)
{
if(healthAmount === 0.0)
Destroy(gameObject);
}
Edit: Sorry, not used to the Javascript syntax
Change GameObject to gameObject
You probably need to add additional logic to this, such as
if(col.gameObject.tag = “Enemy”) // do stuff
It’s javascript…
function OnTriggerEnter(Col : Collider)
{
}
or you meant C#?