Archived

This topic is now archived and is closed to further replies.

Ysaneya

Collision response, spinning

Recommended Posts

I am working on the physics/collision part for a racing game. The collision detection works well, and is based on accurate sphere/mesh intersections. But i''m having two problems with the collision response: 1. Say that my "car" has an up velocity (in the 2D case) and is moving paralell to a wall (in black on the next figure). Then there is a curve: At the moment, my object follows the red path, which is what i want. BUT, look at the yellow vector. It represents the current heading (view vector). In my game the velocity and the view vector can be different. I want the heading to stay paralell to the wall in that case, so i need to make the object spin a bit to the left each time a contact is detected. In an early test i did that just by rotating the view depending on the input/output velocities directions, and it works fine except.. it''s not a perfect curve; it''s approximated with polygons. As a consequence, the spinning is done by step of 30° (more or less), and looks jerky. How can i fix that? How can i implement correct spinning with angular velocities/accelerations, that will, after the end of the curve, give me the second yellow vector? Y.

Share this post


Link to post
Share on other sites
My suggestion is to use a Catmull-Rom interpolation or a Hermite spline interpolation. You could calculate the current location of your object then calculate a position slightly ahead of it and computer a "view vector." This would give you a smooth path along the wall. If you need help with the above interpolations... ask around.

Share this post


Link to post
Share on other sites