- Home /
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
Answer by ZenithCode · Feb 21, 2013 at 08:21 AM
Try these 2 changes.
- Set Collider to 'Trigger' (Checkbox on collider) 
- Add a rigidbody on at least 1 of the cubes. 
Thanks for your answer
I just tried that. If I set the trigger on the moving cube, the player, that's standing on it, falls through it. When I add a rigidbody to it, it moves weird because of physics.
Any other ideas?
Thanks, mitti2000
Your answer
 
 
             Follow this Question
Related Questions
OnTriggerEnter with exact spot of collision 2 Answers
Keep doing something while colliding 1 Answer
Destroying an object on collide depending on the impulse magnitude. 0 Answers
Collision problem in C# 4 Answers
2 objects collide, need to destroy one 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                