View Full Version : Collision response
06-08-2001, 06:01 AM
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.
Ps. I have a working collision detecion. Ds
06-08-2001, 09:32 AM
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.
06-08-2001, 10:11 AM
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.
06-08-2001, 11:46 AM
Thanks for your help guys!
ABout the ball going through the landscape... I honestly didn't test that yet... :-/
I guess was hoping the framerate would be high enough (and the ball always slow enough)not to miss any collisions, but when i think about it I can see how this might become a problem. At the time my landscape is nothing more than a rather simple kind of a miniature golf course.
Well... Thanks again and feel free to add anything you think I should take into account!
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.