when player run and hit ground it destroy

the player is running and collect the coin when it hit any thing it destroy it but i only destroy the coin here is the code plz edit it [76246-coin.txt|76246]

using UnityEngine;
using System.Collections;

public class coin : MonoBehaviour

 int  coinConter ;
//Use this for initialization
void Start () 
	coinConter = 0;

// Update is called once per frame
void Update () {


void OnControllerColliderHit(ControllerColliderHit hit) {

		 Debug.Log (" Hitted " + hit.gameObject.name);
		 Destroy (hit.gameObject);
		 Debug.Log ("coin conter = " + coinConter);



If you are gonna make your character collect something, i think is better you use OnTriggerEnter collision. Don’t forget to mark your collider as trigger.


    void OnTriggerEnter(Collider coll)
        if (coll.gameObject.tag == "Collectible")