- Home /
Question by
austen · Oct 10, 2011 at 06:35 PM ·
javascriptcollisiondestroy
OnCollisionStay for seconds then destroy
what i want is when a gameobject collides with a wall for some seconds then the wall will be destroyed. heres the script on the wall
var Touched: float = 0.0;
var DC: float = 1.0;
function OnCollisionStay (other:Collision)
{
if (other.gameObject.name=="enemy")
{
Touched += DC * Time.deltaTime;
}
Debug.Log(Touched);
if (Touched >= 1000) {
Destroy(this.gameObject);
}
}
but as soon as the object touches the wall without waiting it is destroyed. any ideas?
Comment
Your answer
Follow this Question
Related Questions
collision script to destroy 2 Answers
Destroy on Collision? 1 Answer
Destroy object on collision and update script. 2 Answers