How to get collisions on Character controller?

I have the player with a character controller on him and an object with a box collider and a rigid body on it. What function do I need to use to get the collision between the two? I have tried OnCollisionEnter and OnControllerColliderHit in both objects and I’m getting nothing.

Use OnControllerColliderHit in the player script - but be aware that it will report collisions with the ground all the time (except when the player is jumping, of course). To filter out these collisions, you can check the hit.normal angle from the ground - if it’s below a low angle (say, 45 degrees) the character collided with other thing than the ground:

function OnControllerColliderHit(hit: ControllerColliderHit){
  if (hit.normal.y < 0.707){
    // character collided with another thing (not the ground)
  }
}

This works because normal.y is numerically equal to the sin of the angle from the ground (it’s a normalized vector).

Another alternative is to check if the object hit has a rigidbody, ignoring those that don’t have it:

function OnControllerColliderHit(hit: ControllerColliderHit){
  if (hit.rigidbody){
    // character collided with a rigidbody
  }
}