Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I've been building a small racing game in C#, and I've hit a bit of a block when it comes to the impulse resolution of the car to car collisions. At the moment, the cars are able to hit and push each-other, but there's no resulting rotation from these collisions.

The problem I'm having is determining the point of impact.

I'm using a set of Vector2s to represent the outline of the car. From this, I'm using SAT to determine if there is an collision. While looking for a separating axis, I'm also keeping track of the axis of least penetration, this is the axis that gets used as the normal for the impulse resolution when there is a collision. The axes that I'm using are the normals of the sides of the cars that are being checked for collision.

The collision detection part of this is working very well; the way that the cars are able to shove other cars out of their way isn't too bad either. But, I want the cars to be able to spin out of control when hit at an odd angle.

The best solution I've thought of so far goes something like this:
* CarA is set to the car who's side is being used to determine the normal for the impulse resolution.
* CarB is the other car.
* I push the cars apart to get rid of any penetration (they will still be touching, just not overlapping)
* I use the point of CarB that is nearest to the impacted side of CarA, as the point of impact.

As far as I can tell, this solution seems sound, but I'm being bothered by one thing. What if it's a flat side-to-side hit? A perfect head-on-collision of two cars playing chicken would be a good example of what's bothering me.

Does anyone have any advice on what might be the best course of action for this?
Posted
Updated 13-Jul-14 18:09pm
v2

1 solution

I ended up using the point of minimum extent along the normal axis, from CarB. It's the possible solution I mentioned in the question. Things are a little bouncy, but I think that has more to do with the constants I'm using. Besides, most people that have tried the game out tend to get a bit of a smile from that, so I think I'll be keeping it that way.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900