#StackBounty: #collision-detection #physics #collision-resolution Issue with 2d Angular Car Collision Response

Bounty: 50

I am having trouble getting the angular collision response to work properly in my 2d car simulation. I have gotten the linear collision response to work between the vehicles, however, the angular collision response does not seem to be working. The problem seems to arise from my slip angle calculation for the car, and it seems to override the angular impulse. The slip angle is necessary to make the vehicle move realistically.

Here’s the code to calculate the slip angle:

// Calculate slip angle for front/back wheel
this.wheels.front.slipAngle = -Math.atan2(this.localVelocity.y + yawSpeedFront, Math.abs(this.localVelocity.x));
this.wheels.back.slipAngle = -Math.atan2(this.localVelocity.y + yawSpeedRear,  Math.abs(this.localVelocity.x));

As can be seen in the following pictures, the car rotation response is correctly simulated when it hits the top of the car and rotates clockwise. On the other hand, when the car hits the bottom of the other car, the rotation should be clockwise, but actually still goes clockwise. It seems to me that the problem arises because the slipAngle overrides the angular rotation of the collision.

enter image description here

enter image description here

My project can be seen here: https://victorwei.com/projects/car-sim/ Feel free to take play around with the simulation and view the code to figure out the issue. If there are any suggestions on how to mitigate this problem, that would be greatly appreciated.

Get this bounty!!!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.