2d Car with wheels?

Dec 20, 2007 at 7:38 PM
I'm trying to create a simple 2d side view of a car and I could use some advice!

So I made a car body, which is created with polys, and two wheels, which are simple circles.

Now, how do I attach the wheels to the car? (which joints should I use?) I've tried linear springs which make for good shocks but I haven't gotten it working as well as I would like.

Also, what is a good way to make the car move forward? I haven't had much success putting forces just on the wheels. If I just apply a force to the car body, it becomes rocket car, which isn't quite what I want...

Ideas? Has anyone done this?
Coordinator
Dec 20, 2007 at 8:01 PM
Use RevoluteJoints for the wheels, The joints work like Axles. To move the car use ApplyTorque on the wheels. You will need to tinker for a while to get the right balance of torque and friction etc.. but that is how you want to do it I think.

-Jeff
Dec 21, 2007 at 3:21 AM
Ok, I have the joints and am applying torque.

At moderate speeds the car starts bouncing up and down a lot. (the surface it is driving on is a flat rectangle)

Any suggestions to reduce the bouncing? I've tweeked a bunch of numbers for not much success.
Dec 21, 2007 at 11:28 AM
How did you configure the joints/controllers?

I've been trying to create a similar system. I have a box that acts as the chassis, and two circle bodies representing the wheels.
But I cant figure out how to connect the wheels to the chassis, and restricting them to a linear spring motion.
Slide joints only seem to limit distance, actual movement is free. Tips?

When it comes to bounciness, try to reduce RestitutionCoefficient on the wheels, and balance the weight between the wheels and chassis.
Restitution does a whole lot for instable systems (at least when I simulated "ball baths").
Dec 21, 2007 at 3:04 PM
RevoluteJoint rev1;
RevoluteJoint rev2;

rev1 = JointFactory.Instance.CreateRevoluteJoint(ps, wheel1.Body, frame.Body, new Vector2(wheel1.X, wheel1.Y));
rev2 = JointFactory.Instance.CreateRevoluteJoint(ps, wheel2.Body, frame.Body, new Vector2(wheel2.X, wheel2.Y));

This allows the wheels to rotate on axis.

You'd have to put a linear spring in between that joint and the body for shocks. Perhaps two shocks per wheel would limit movement better?
Coordinator
Dec 21, 2007 at 7:03 PM
About the bounciness, this could also be because of the wheels. They are not 100% round because they are made of polygons. Try increase the amount of polygons that make up the wheels.

You could also try playing with the mass of the car.
Dec 22, 2007 at 2:46 AM
Some updates:

A big thing that helped is reducing the simulation step size from .01 sec to 0.002 sec.

Also, adding a RotationalDragCoefficient of about a 100 made a big difference. Now the car seems pretty stable.

@genbox - yes increasing the poly count of the wheels did help. They seem to work well at around 100 sides.

Thanks for all of the tips everyone! now time to try to add shocks...