checking where the ball was hit by an object

I got a bouncing ball, and i want to set a condition that will execute when my ball is being collided with the bottom of his collider. it has a box collider, when the bottom of the collider is hit by other object the condition i want will be executed. how do I do that?

Easiest way is to separate your collider in sub colliders. At the moment, you have one box collider for the whole ball, make it two on two children.

This way you can still get the collision from the top children if you need so and you get from the bottom one to perform the specific action.

One solution would be to check if the difference between the positions of the colliding objects points ‘away’ from the object’s local down.


void OnCollisionEnter(Collision collision)
    float dot = Mathf.Cos(90f * Mathf.Deg2Rad);
    var direction = collision.transform.position - transform.position;
    if (Vector3.Dot(-transform.up, direction) >= dot)
        Debug.Log("Hit from bottom");

You can make the angle tighter be reducing the 90f. You could also change the -transform.up in the Vector3.Dot to -Vector3.up if you only care about world space.