- Home /
How to make an event happen after an object is collided with
how can I destroy an object after a different object is collided with?
Answer by Meltdown · Mar 28, 2011 at 05:28 AM
Add this line of code to either of your objects that are colliding...
function OnCollisionEnter() {
Destroy(gameObject.Find("Box"));
}
Where Box is the name of the object you wish to destroy when the collision happens..
http://unity3d.com/support/documentation/ScriptReference/Object.Destroy.html
Answer by flaviusxvii · Mar 28, 2011 at 04:36 AM
Up on the top right there is a white box with a little tiny banjo in it. In there type 'destroy collide' and hit your enter/return key.
Look around a bit and you'll find examples.
Your answer
Follow this Question
Related Questions
Object Not Destroying? 1 Answer
Pickup Bullets 1 Answer
destroy object in front of an other object? 1 Answer
Problem with destroying a gameObject when used with targeting 1 Answer
Player colliding with object then destroying/killing Player 2 Answers