- Home /
Question by
manumaniche · Jan 22, 2014 at 03:04 PM ·
triggerdestroy
using trigger to destroy a specific object?
I am trying to use trigger to destroy a door object when the box object collides with trigger. But the code is not working, I have trigger in place and box can pass through it but doesn't destroys the door. I have placed this code in trigger object.
function onTriggerEnter (other : Collider){
if (other.tag == "box"){
Destroy (gameObject.Find("door"));
}
}
Comment
Answer by MarkD · Jan 22, 2014 at 04:52 PM
if the script is on the door, check if it is colliding with the player (your box?) because your script is looking good. Else try instead of onTriggerEnter, onCollisionEnter.
Your answer

Follow this Question
Related Questions
Putting an object somewhere to destroy something else 1 Answer
destroying instructions sequence 1 Answer
Kill enemy when animation is playing 1 Answer
gui does not appear after trigger? 1 Answer
Why won't the collision work? 3 Answers