Car Game

Aug 27, 2007 at 11:19 AM
I'm working on a top down driving game using Farseer but i'm having some trouble, is there a way for me to stop the car from sliding sideways or at least minimise it? I've used LinearDragCoefficient to add drag for when the car goes forwards and backwards but i'm not sure how to adjust sideways movement.

thanks for any help.
Aug 27, 2007 at 8:50 PM
You will need to calculate some tire-friction forces and apply them using the ApplyForceAtPoint method. Basically you will be applying lateral forces at the tire positions to prevent/reduce sliding.

I know there are some pretty good white papers on the web that should help you calculate the friction you will need. I don't have any links but Google should be able to find something.
Aug 28, 2007 at 7:55 AM
thanks, i'll see what i can find.
Sep 3, 2007 at 12:39 AM
Edited Sep 3, 2007 at 12:40 AM
I think it'd be a really cool addition if Farseer could simulate treads or tires from a top-down perspective like that: Objects that have little friction going in one direction and incredible friction going in the other that can be "attached" to PolygonEntitys the same way SpriteEntityViews are.

For a quick fix to that problem now, you probably aught to simply get the object's LinearVelocity, calculate a new Vector2 equal to the portion of LinearVelocity that's parallel to the object's orientation, and set LinearVelocity to the Vector2. To make skidding possible, you can calculate the perpendicular Vector2 and multiply it by one of two scalar values, depending on whether the net speed is greater than a certain threshold. By using two friction coefficients here you can simulate static friction. Then, set LinearVelocity to the sum of the two Vector2s you just calculated.
Sep 4, 2007 at 11:31 AM
Currently the feature list is frozen for the next release. This seems like something that might be handled in a demo. I'll hopefully have time to give it further consideration/thought in the future.