OnCollisionEnter called while box colliders not touching


I’ve got a problem with Unity3d 5.5 and OnCollisionEnter that is called when objects are near but not touching themselves.

I create a simple scene with 2 Cubes (3d) Scale=1x1x1, Box Collider Size=1x1x1, and RigidBody (not using gravity)

I position “Cube1” at 0x0x0 (left cube) and “Cube2” at 4x0x0 (right cube) (Cube2 should touch Cube1 when Cube2.transform.position.x = 1)

I assign the following Script to Cube2:

	using System.Collections;
	using System.Collections.Generic;
	using UnityEngine;
	public class CollisionDetector : MonoBehaviour {
		private void OnCollisionEnter(Collision collision)
			GameObject other = collision.gameObject;
			Debug.Log(string.Format("ENTER: {0} (Pos={1},{2},{3})", other.name, transform.position.x, transform.position.y, transform.position.z));
		public void OnCollisionExit(Collision collision)
			GameObject other = collision.gameObject;
			Debug.Log(string.Format("EXIT: {0} (Pos={1},{2},{3})", other.name, transform.position.x, transform.position.y, transform.position.z));
		public void OnTriggerEnter(Collider other)
			Debug.Log(string.Format("TRIGGER ENTER: {0} (Pos={1},{2},{3})", other.name, transform.position.x, transform.position.y, transform.position.z));
		private void OnTriggerExit(Collider other)
			Debug.Log(string.Format("TRIGGER EXIT: {0} (Pos={1},{2},{3})", other.name, transform.position.x, transform.position.y, transform.position.z));

I press Play

If I change in editor the X of Cube2 Transform Position and make it smaller in order to get closer to Cube1, the event OnCollisionEnter is called when the X = 2.8 (Cubes are not touching themselves!!!)
Console Log: ENTER: Cube 1 (Pos=2.8,0,0)

Also when I separate the cubes changing the position X of Cube 2, OnCollisionExit is called when Cube2 X = 2.8
Console Log: EXIT: Cube 1 (Pos=2.81,0,0)

If I set the Box Collider of Cube 2 as “Is Trigger”, then the functions OnTriggerEnter and OnTriggerExit are called ok when Cube2 X position = 1
Console Log: TRIGGER ENTER: Cube 1 (Pos=0.94,0,0)
Console Log: TRIGGER EXIT: Cube 1 (Pos=1.04,0,0)

do you know why is failing OnCollisionEnter and OnCollisionExit?

Thanks for your help!!!


In the next url, you can download the zip with the project folder: https://www.dropbox.com/… (removed)

If I export it as a package and import that package in a new project… it works fine ???

Any explanation? Help please!!!

Thank you very much for your help


I comment, in case someone has the same problem:

I had been testing the PhysicsManager properties (Edit/Project Settings/Physics) and I had the “Default contact offset” set to 0.9 instead of the default value 0.001, so collisions ocurred 1.8 units further than they should.