- Home /
how do i destroy another object after collision?
I have two boxes, box1 and box 2..
how can i destroy box 2 after colliding with box 1?
And by the way, what's the opposite of destroy in unity? like for example, i have box4 and box5, after colliding with box 4, box 4 will be destroyed and box 5 will be visible?
i bet this would be simple for you guys, sorry i'm a newbie, struggling for this simple prob.. :) Hope you could help me out :)
Answer by Jesse Anders · Dec 19, 2010 at 04:02 PM
how can i destroy box 2 after colliding with box 1?
You can use the OnCollisionEnter() function to perform actions in response to collision events, and you can use the Destroy() function to destroy game objects. You can use these together to destroy an object when a collision occurs.
And by the way, what's the opposite of destroy in unity? like for example, i have box4 and box5, after colliding with box 4, box 4 will be destroyed and box 5 will be visible?
In this case, the opposite of destroying an object is simply not destroying the object.
ahh..Thanks for that..i'm just a little confused witht he Destroy() i've tried destroying an object which was hit by the person, but destroying an object by it's tag..i really can't figure it out..
hmm, how about if it's not visible in a scene and it'll be visible after colliding a particular object?
Thanks a lot for the help!
Your answer
Follow this Question
Related Questions
When all objects with a certain tag has been destroyed, load the next level! 3 Answers
The object of type 'Transform' has been destroyed but you are still trying to access it. 1 Answer
My game has been deleted 2 Answers
how do i create a game object array with gameobjects of multiple tags 1 Answer
Destroy only selected object 1 Answer