- Home /
early collision above character controller
I have a basic character controller on the main character of my game. For some reason all collisions that happen on top of the character are happening way before there is an actual collision. For example in the picture below you can clearly see that the capsule is not colliding with the box colliders above the character. However OnControllerColliderHit is being triggered and if (controller.collisionFlags & CollisionFlags.Above) != 0 is reading true which means there is a collision above the character.
To make things stranger if I set isTrigger to true on the colliders above the character the OnTriggerEnter() method does not have the same problem as a standard collider.
Also as you can see the character is on the ground so obviously the collision detection below the character is working
Does anyone know of a way to fix this problem? Is this a bug in Unity?
Answer by TheValar · Feb 22, 2013 at 01:45 AM
Solved this a while ago (sort of) and I thought I'd post the fix here just in case. I was able to get it to work properly by reducing the stepHeight on the character controller. I guess it's just a bug with that script.
Answer by JamieFristrom · Nov 12, 2012 at 09:16 PM
You aren't supposed to check the controller's colliderFlags from within OnControllerColliderHit, which doesn't explain your problem ((controller.collisionFlags & CollisionFlags.Above) should still == 0) but maybe you'll have better luck if instead of using OnControllerColliderHit you check the collisionFlags returned from Move after you call it.