Question by
LogansTightAss · Jan 27, 2016 at 03:01 PM ·
javascriptcollisionvariable
how do i make an object destroy after multiple collisions?,How do i create a script that destroys an object after multiple collisions?
//Test Block script
var health = 100.0;
function OnCollisionEnter(theCollision : Collision)
{
if (theCollision.other.gameObject.tag == "Player")
{
if(health <= 100.0)
{
health -= 50.0;
}
else if (health <= 50.0)
{
health -= 50.0;
}
else if (health <= 0.0)
{
Destroy(gameObject);
}
}
}
,
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612061838im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Javascript error on runtime semi colon required 1 Answer
Help with variables 1 Answer
Make object fall when user enters space 1 Answer