- Home /
The question is answered, right answer was accepted
Destroy an object with another one.
Hi, I want to destroy an object (in this case a chain) when its touched by another object (a bolt cutter). I made the bolt cutter pickuable like in Amnesia and I want to make so when you go with the cutter in the chain, the chain will be destroyed. Hope you understand what I want. Is there a way i can do this ? Thank you!
Do you mean full on realism? You cut a small piece of the chain and then both parts fall off on their own? Or do you mean calling the Destroy function?
I mean using the Destroy function. I need to use the box collider from the chain object and make a script saying that when the object(Bolt cutter) enters the chain's box collider destroy the chain object or something like that, right ?
Answer by bubzy · Jun 23, 2013 at 08:20 PM
 //pseudocode
 
 OnTriggerEnter(collider other)
 if(other.tag == "boltcutter")
 {
 destroy(gameObject)
 }
you might want to check out the onTriggerEnter section of the scripting reference
http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.OnTriggerEnter.html
Thank you, it work perfectly, there were some erreors (I don't know if you if you put then intentionally), but i figured it out by looking at the link. The final code is:
 function OnTriggerEnter(other : Collider){
 
     if(other.tag == "boltcutter") {         Destroy(gameObject);     } }
not intentional errors, just not actual code :) mark the answer as accepted to clear up the list :)
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                