Function OnTriggerEnter (494396)

Hi,

Please look at this code, In this code every time a rigidbody object reaches to trigger a code get play

function OnTriggerEnter (other : Collider){   

  

   rigidbody.AddForce (-1, 0, 0);
   
   
  }

But I don’t want all objects that have rigidbody will effect that, For example I just want only Cube2 effects this trigger

function OnTriggerEnter (other : Collider){   
 
    if(gameObject.name == "Cube2"){
      rigidbody.AddForce (-1, 0, 0);
     }
   
  }

Just check the gameObject name of the object entering the trigger. Or you could keep your code the way it is and only attach the script to the objects you wish to behave that way.

Thanks, This solved by using tag