Destroy on collision

I am making a game, that if a car collide with a coin, the coin will disappear. but I have no idea what script i need… so please make a reply and give it!

Attach this to the coin:

function OnCollisionEnter ( )
{
   GameObject.Destroy ( gameObject ) ;

}

Also, be sure to add a Rigidbody and Box Collider. The object colliding into the coin also needs a rigidbody, and box collider. (PS: Do not attach this script to the player lOl. Bad results :wink: )

Try this :slight_smile:

  public void OnCollisionEnter(Collision node){
        if(node.gameObject.tag == "Coin")
        {
            Destroy(node.gameObject);
        }
  }

or this

  public void OnTriggerEnter(Collider node) {
        if(node.gameObject.tag == "Coin")
        {
            Destroy(node.gameObject);
        }
  }

In Javascript in would be:

    function OnTriggerEnter(node : Collider){
               if(node.gameObject.tag == "Coin")
        {
            Destroy(node.gameObject);       
        }
    }

Or

    function OnCollisionEnter(node : Collision){
               if(node.gameObject.tag == "Coin")
        {
            Destroy(node.gameObject);       
        }
    }