webcaetano / quickb2

Automatically exported from code.google.com/p/quickb2
0 stars 0 forks source link

TopDown: Lateral and Longitudinal Weight Transfer #32

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Inside tdCarBody, when you compute the weight transfer you should clamp the 
final value.

Now:
var longTransfer:Number = vertDiff ? (zCenterOfMass / vertDiff) * totMass * 
_kinematics._longAccel : 0;
var latTransfer:Number  = horDiff  ? (zCenterOfMass / horDiff)  * totMass * 
_kinematics._latAccel  : 0;

Then you should add:
longTransfer = amUtils.constrain(longTransfer, -totMass, totMass);
latTransfer = amUtils.constrain(latTransfer, -totMass, totMass);

In this way you prevent that the car start to spin around itself, due to the 
wrong weight transfer.

Original issue reported on code.google.com by magi...@gmail.com on 21 Jul 2011 at 2:34

GoogleCodeExporter commented 9 years ago
Interesting.  Indeed I have had problems with this in the past.  The 
fundamental issue sometimes is that it's a 2d simulation, and there are 3d 
forces at work that can't be simulated, so they have to be sent to 2d.  
Sometimes this results in weird effects where in 3d the car would flip over, 
but in 2d it has to stay flat, and those forces have to go somewhere.

I will experiment with this clamping to see if it gives good results.  Maybe 
make the clamping customizable in some user-friendly way, to make a car spin 
more or spin less.

Thanks for the tip!

(P.S. I've added your other changes, but haven't had a chance to commit yet)

Original comment by doug...@gmail.com on 22 Jul 2011 at 1:54