Click here to Skip to main content
13,632,483 members
Rate this:
Please Sign up or sign in to vote.
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 15-Nov-13 13:53pm
Updated 13-Jul-14 18:09pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web03 | 2.8.180712.1 | Last Updated 14 Jul 2014
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100