Click here to Skip to main content
15,894,405 members

Finding the Point of Impact for an Impulse Resolution

Francisco T. Chavez asked:

Open original thread
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?
Tags: C#, Game Development, XNA, Simulate, Collisions

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



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