Collision response, spinning

Started by
1 comment, last by Ysaneya 20 years, 9 months ago
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.
Advertisement
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.
Read about Steering Behaviours.

You need to know path following behaviour.
3D Side-Scroller game demo Project-X2 "playable"Lashkar: A 3D Game & Simulation Project demo @ lashkar.berlios.de

This topic is closed to new replies.

Advertisement