# OnCollisionEnter is called over and over again

Currently I'm trying to let the player place a GameObject in the world. You can imagine this like a RTS game where you can place a building you have just build.
My problem now is, in order to avoid that the new GameObject intersects with another I check for collisions. For this my GameObjects have a BoxCollider (MeshCollider did not work) and a non kinematic RigidBody.
The first tests looked promising but now I'm facing a problem I can't quite explain: Sometimes, but not always OnCollisionEnter and OnCollisionExit are called over and over again, even when both objects are not moving. They overlap and stay that way. I had guessed that they always only get called once.
My Unity version is 5.3.0f4.

Further information: Each of my GameObjects have a guid so I can identify. They get generated when the GameOject is created. The debug output in OnCollisionEnter and Exit look like this:

OnCollisionEnter from 593b209f-cc63-4d31-9911-34c5f69ac224
Collided with: 593b209f-cc63-4d31-9911-34c5f69ac224
OnCollisionExit from 593b209f-cc63-4d31-9911-34c5f69ac224!

And then the same output again.

I'm happy for any hints and help. :)

• Can you explain further more about repetition and frequency of this happening? – Hamza Hasan Dec 13 '15 at 21:44
• Are you modifying its transform.position every frame? Because this causes the Rigidbody to basically "leave" its current position and "enter" anew. If so, try using Rigidbody.MovePosition instead, which is the cleaner way to move an object that has a Rigidbody. – Chris McFarland Dec 13 '15 at 22:07
• @HamzaHasan: This happens about every second time I place the object. The loop also repeats when the game object gets destroyed. I have no reference anywhere anymore and call Destroy on the game object. – Skalli Dec 13 '15 at 22:36
• @Chris: No, the object's don't move. The only motion that might get applied (which I disabled for testing purposes but the problem kept happening) was RotateAround of the all the GameObjects within it's parent. No transform.position anywhere. – Skalli Dec 13 '15 at 22:38
• @Chris: I've checked the RotateAround again and not only set rotation to 0 but commented out the line entirely. Now the problem seems not to be happening anymore. This might be the cause, I will do some further checks. – Skalli Dec 13 '15 at 22:46