Counter problem

Hi. I am a beginner in Unity. I am doing the Challenge 03 (Unity 3D Student - 3d Modelling) and got some problems. I have written a script.

var Counter :int =0;
function Update(){
var fwd =transform.forward*100;
function OnCollisionEnter(theCollision:Collision){
if ("smalltarget" ){
   //not Destroy(gameObject.Find("smalltarget");
   //tried also Counter+=1

Debug.Log("smalltarget destroyed");
if (Counter >=3){
Debug.Log("now scene must be loaded");

The problem is that the Counter number remains 1 in Debug.Log and it is not rising. What should I do? Could you help me please?

  • What is the Log printing out?
  • Which GameObject/prefab is this script attached to?
  • Line 9: Destroy(gameObject); seems to be destroying the current object and by extension this instance of the script, if any other instances of this script exist on other gameObjects in your scene they will have their own counter variable, that will hold independent values.