Collision detection between box collider and character controller

Hi

I am new on unity3d i am facing a problem on collision with my character having character contorller to an object having box collider. I have found that character controller collision can be detected using

void OnControllerColliderHit(ControllerColliderHit hit)

but this is only work and called in script which is attached with character having character collision so when i use the onControllerColliderHid it call every time which ever thing is collide with it like if my character is walking on road it called. So now what basically i want is to detect collision onCollisionEnter in the script which is attached with box having box collider and when the character collide with that box that onCollisionEnter should called but it’s not calling due to character controller on my character if i add box collider on my character then it always call. However if i make the box collider istriggered then OnTriggerEnter called either character have character controller or box collider but it’s not working if i just uncheck the triggered. so can any one help me in this

Yes, OnControllerColliderHit is only sent to the CharacterController’s script, and only when the character hits the collider (nothing happens when the collider hits the character). If you want to call some function in the other object’s script, use SendMessage in the character script:

void OnControllerColliderHit(ControllerColliderHit hit){
  hit.transform.SendMessage("SomeFunction", SendMessageOptions.DontRequireReceiver);
}

This code calls the function SomeFunction in the other object’s script, if it exists. In order to improve performance, it would be better to SendMessage only to the desired object - by comparing its tag, for instance:

void OnControllerColliderHit(ControllerColliderHit hit){
  if (hit.transform.tag == "SomeTag"){
    hit.transform.SendMessage("SomeFunction", SendMessageOptions.DontRequireReceiver);
  }
}