- Home /
Detect Collision between 2 objects
Hello,
I have two moving cubes with attached box collider and rigidbody. I want to detect the collider when they touch each other and run a script to stop moving.
Any help would be highly appreciated.
Comment
Answer by Jessy · Jan 13, 2011 at 11:54 PM
function OnCollisionEnter (collision : Collision) {
rigidbody.Sleep();
collision.rigidbody.Sleep();
}
Make it more complex if necessary. I assume you need to check to see if the cubes are what collided, but you haven't specified.
Thanks Jessy. What I want exactly is : when I move one of my cube by mouse can't put this cube on the place which the other cube is . At this moment when I move one of my cube and try to put on the other cube, they touched each other and the both go out of my secen. Actually I want detect that the touched each other and control their move . Any help would be regarded .