CharacterController - multiple objects collision detection?


I’m working on a 3D endless runner and for my player object I’m using a CharacterController.

It detects collision just fine using the OnControllerColliderHit callback.

Today I tried creating some obstacles that can only be avoided by rolling under. If the player rolls too early the character would rise from the roll and hit the obstacle above it.

The problem is that the collision with the object above the CharacterController object is ignored and only the collision with the ground object is detected.

void OnControllerColliderHit(ControllerColliderHit h)

        if (h.normal.z < -0.9f || h.normal.y < -0.9f || Utilities.Abs(h.normal.x) > 0.5)

This is how I trigger the GameOver sequence. It works fine for first and last condition, but the 2nd condition doesn’t work because the h.normal, in the case described above, is the ground’s normal which is = Vector.up .

Does anyone know if there’s a way for detecting collision between multiple objects at the same time using the CharacterController component? Or a workaround for this that does not involve using a Rigidbody.

Thank you!

I am looking the answer for similar type of question. Let me know if you figure out. Thank You :slight_smile: @laurG

I found a workaround for this that involves raycasts.

At the moment where the character should rise from the roll, I shoot a raycast upwards and check if it hit anything/obstacle.