- Home /
 
destroying object upon collision
im trying to collide with an object and add gold to my money system script and destroy it it is adding the gold now i need it to go away. heres my script so far .
 var gold : int = 20;
 
 
 function OnControllerColliderHit(hit: ControllerColliderHit){
   if(hit.gameObject.tag == "Gold" ){
         moneysystem.Gold =++  gold ;
         Destroy(other.gameObject);  
          
          }                                             
          }
 
              Answer by slayer29179 · Aug 21, 2012 at 01:44 AM
I don't get what the other is but if you want to destroy the coin provided this script is attached to the character you could put
 Destroy(hit.gameObject);
 
               and if its attached to the coin its self put
 Destroy(gameObject);
 
               Hope this helps!! :)
yes Destroy(hit.gameobject) worked like a charm thank you .
No problem! :) Please click the Tick next to my answer so this question is marked as finished :)
Your answer
 
             Follow this Question
Related Questions
A node in a childnode? 1 Answer
How do i assign multiple (diffrent) objects in array? 1 Answer
Trouble with video 0 Answers
Triggering door animation with collider 2 Answers
Pickup Bullets 1 Answer