This project has moved and is read-only. For the latest updates, please go here.

Collision response problem

Dec 13, 2008 at 1:22 PM
I've got a car made up of a rectangle and two circles for the wheels, but I've come across a strange bug. It seems like when the wheels are turning one way, they collide with the ground fine and the car stays on top of the ground, but if they are spinning the other way, they seem to suck the car through the floor. The floor is made up of 1x1 blocks, and the car is about 2 units wide. Each wheel has a diameter of about 0.8. I've tried subdividing the blocks, and the wheels have quite a high number of edges. I've got max detected contacts set to 3 and max resolved contacts set to 2. If I increase these, the problem isn't as bad, but is still noticable. I think what's happening is that it's detecting collisions on the left hand side of the wheel, and ignoring ones on the right, because the max contacts is set low. Then when it calculates the relative velocity of that part of the wheel, it pushes the car away from the block when the wheel's turning one way (as the velocity on the contact point is going towards the floor), but pulls it into the block if the wheel collides but the collision points are moving away from the block. I've tried to debug the code, and it seems like this is what's happening (when the wheel is turning backwards, the numbers for the NormalImpulse tend to be more negative than when it's going forwards), but I'm not entirely sure if I'm on the right track, or what the proper way to fix it is. Any help? Thanks.
Dec 14, 2008 at 4:50 PM
What do you mean by 1x1 blocks, 2 units and 0.8? I sure hope it's not pixels :)
Dec 15, 2008 at 10:24 AM
Maybe you have the same problem as I had... try to decrease PhysicsSimulator.AllowedPenetration.

My thread for this problem :)
Dec 16, 2008 at 2:16 PM
The units are all whatever units Farseer uses. E.g for a 1x1 block, length = 1.0f, width = 1.0f. The car is about 2.0f for the length, and 1.0f for the width, and the wheels are about 0.4f for the radius. I think I've got the problem solved anyway. Looks like it was this:
Dec 16, 2008 at 6:19 PM
Ok. I was wondering on the units since they are very small values, but Farseer Physics don't care if the simulation is "small" (Scaled down compared to the drawing) or "big". Well, actually this is not 100% true as it prefers small values as it can calculate faster on small values.

Anyway, glad that you fixed your problem.