I have a player which is using the ThirdPersonController from the 3D platformer tutorial. I’ve also added a SphereCollider to my player and I added the OnCollisionEnter function to the ThirdPersonController script. Which looks like
function OnCollisionEnter(collision : Collision)
{
print("OnCollisionEnter");
}
I’ve also added an empty game object to my scene and attached a Rigidbody and a BoxCollider to it. When my player walks into the empty gameobject’s BoxCollider, nothing print out in the debug console.
If I stop the scene and uncheck gravity and start the scene, I can see the BoxCollider start to float up. Now if I run into it, OnCollisionEnter is printed out. I only get this behavior if I uncheck gravity on the Rigidbody before I start the scene. If the scene is already running and I uncheck it, the BoxCollider doesn’t start to float up and walking into it produces no output.
Why won’t OnCollisionEnter fire with gravity turned on? Also, why does disabling gravity cause the object to float? Shouldn’t it stay in place until some force acts on it?
edit: I still can’t figure this out. I don’t see why 2 colliders can’t collide with each other. And for some reason, in this case a collider and rigidbody with a collider attached won’t even collide with each other.