Collision counts only once

hi.

i am writing a script with which it counts up the amount of children the player found if he collides them. but how can i achieve that the collison will only work once for each child, so that if the player collides with one, he already has collided with, it will not count up again? thanks a lot!!

here is my sript:

static var childCount : int = 0;

function OnCollisionEnter (hit : Collision)

{
    if(hit.gameObject.tag == "Player")

    {
    	ChildCounter.childCount += 1;
  	}

Create another script and put it on the child. Declare a boolean value called “isHit” in that script and set it’s default value to false. Then once it’s collided, find that script on it and set it’s boolean to true.

function OnCollisionEnter(col : Collision) {
    if(col.collider.gameObject.tag == "Player") {
        var hitObjectScript : ThatScript = col.collider.GetComponent(ThatScript);

        if(hitObjectScript.isHit == false) {
           hitObjectScript.isHit = true;
           ChildCounter.childCount += 1;
        }
    }
}