Colliding two GameObjects

Hi there

I have a small beginner problem. In my scene I have a cube with a cube collider attached to it. Said cube is moving towards another cube with a cube collider. For testing purposes I just want the Debug console to give me an ok when the the two collide. So I have folling script:

function OnCollisionEnter(collision : Collision){
    Debug.Log("ok");
}

I tried that script on both cubes (not at the same time of course) but I don’t get that ok.

I tried working with triggers as well by setting one of the cubes as triggers:

function OnTriggerEnter (other : Collider) {
    Debug.Log("Ok");
}

No luck there either. I feel like I tried everything but I don’t get the result I expect.
Can someone explain me, what I’m doing wrong?

Thanks
mitti2000

Try these 2 changes.

  1. Set Collider to ‘Trigger’ (Checkbox on collider)
  2. Add a rigidbody on at least 1 of the cubes.