Collision delete

Ok so iv been trying to make a script and keep failing. I want it so that when an object touches another object, a event happens (Such as it prints on the screen "You won!")

  • My box is called "bluecube"
  • My collider that if bluecube collides with it i want something to happen is called "bottom-collider"

so i tried this script - (this failed)

var bluecube : Transform;

function OnControllerColliderHit(collision:Collision)

if(collision.gameObject == "bluecube")


what i wanted it to do is that when the bluecube comes into contact with the object that has this script attached it will destroy the bluecube.

Thanks in advance!

You just need to change this little piece of code:

if( == "bluecube")

Since you're doing it by name, you don't need to have a variable to your blueCube object (though you could also use it for checking if you prefer, e.g. if (collision.transform == bluecube) )