# Collision response

Hi!
I wnat to be able to roll and / or bounce a ball around in an arbitrary shaped landscape… And I want it to be reasonably correct according to physical laws.
Any suggestions?
Thanks!

Ps. I have a working collision detecion. Ds

You say you have working collision detection so I assume you know therefore which face of your landscape the ball hits.

If that the case then physically correct bouncing is quite easy (well…).

You have to calculate the normal of that face. Then (and this is the hard part) you have to figure out the speed the ball was moving parallel to that normal. You invert that value and multiply it by a constant called the coefficient of restitution, e. This should only be a value between 0 and 1. The lower it is the smaller the subsequent bounce. (Note if you have it between -1 and 0 then that will invert the direction for you)

Make sure you only change the speed parallel to the normal. This is quite difficult in 3d maths but then again its a challange.

Ps. How did you get collision detection to work. On my engine if something moves too fast it can shoot throught the landscape in one frame and never collide. Did you manage to solve this problem.

Zadkiel, sounds like a classic case of not taking into acount time in some way or another. You don’t only have to check where the collider is and where it is going but also every point (infinite) inbetween. You need to find the distance to the colliding plane from the initial position this will show you where and how far to move.

Hi!