I've tried several different physics engines for XNA:NFS.
I tried JigLibX first, as it had the coolest vehicle demo, but after a considerable amount of pain getting it integrated, it was difficult to get the vehicle to behave in the same way as the demo. And once it got to a certain speed, it started to rock side to side, with no obvious way to stop it.
Up next was BepuPhysics. This has a pretty basic looking vehicle demo, but was quite easy to integrate.
Basically you define your terrain (from a list of vertices), give it some properties like friction and gravity. Then you create a Vehicle, attach some Wheels and hook up a button press to wheel.Accelerate();
Getting it running initially only took a couple of hours - but trying to figure out values to make the vehicle behave correctly still had me tearing hair out days later.
The problem is that its all a very fine balance of forces. For example, one bumpy part of the track was pitching the vehicle backwards and forwards and looked ridiculous. The solution? Make the suspension softer to counteract the bumps. But making the suspension softer caused it to wallow/float around the corners, sometimes tipping over. The solution? Increase the sideways stiffness, and give the car more mass to stabilise it. This then pushed the softened suspension down too far. And so it went on, round and round.
After almost quitting the whole project, I saw this post which is a simple 2d vehicle physics class. Using it as a starting point, I've ended up writing my own vehicle physics. Granted, it will never be anything as good as what Bepu/JigLibX could produce in the right hands, but it means I can choose which corners to cut and focus on making it a fun experience to drive.
Demo coming soon :)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment