Detecting when an object enters a collider from the top?

My character with character controller rolls around, and sometimes hits my object which has a box collider. I want to do so that if i hit the object from above, the object plays one animation, and if the object is hit from any other side, it should play another.
I know how to do the animation part, so all I need help with is how to detect where the collision happens.

Any ideas how to go about this one?

You could use OnControllerColliderHit in the character script, and check the hit normal: if it’s almost vertical, you’re colliding in the top-down direction. But there’s an issue: this event happens all the time due to collisions with the ground, thus you should filter out the undesired cases checking if the collided object has the right tag. Another problem: the animation code probably is attached to the hit object, not to the character, thus you should pass a hint from the character script to the animation code.

An example: the animation script (let’s call it AnimScript.js) could contain a function like this:

function PlayAnimation(normal: Vector3){
  if (normal.y > 0.9){ // if hit normal angle from horizontal > 64 degrees (sin(64)=0.9)
    animation.CrossFade("TopDownHit"); // play top-down animation
  } else {
    animation.CrossFade("OtherHit"); // play other animation

And in the character script you could have a code like this:

function OnControllerColliderHit(hit: ControllerColliderHit){
  if (hit.transform.tag == "Enemy"){ // supposing the other object is tagged Enemy
    // try to get its script AnimScript.js
    var anim: AnimScript = hit.transform.GetComponent(AnimScript);
    // if script got, call PlayAnimation passing the hit normal:
    if (anim) anim.PlayAnimation(hit.normal);