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

Linejoint doesn't work, Limitenable doesn't work, help me with my suspension

Dec 7, 2011 at 12:26 PM

Hi there Farseer community. I've been really struggling with getting bike suspension working and hope someone can help out. I've tried a number of ways, focusing mostly on either using a LineJoint, or using LimitEnabled with RevoluteJoints, and I can't get either to be 100%. An example of one of the joints at the moment is here:

            backFork = BodyFactory.CreateRectangle(theWorld, ConvertUnits.ToSimUnits(backfork.Width), ConvertUnits.ToSimUnits(backfork.Height), 1f);
            backFork.BodyType = BodyType.Dynamic;
            backFork.CollisionCategories = Category.None;

            backWheel = BodyFactory.CreateCircle(theWorld, ConvertUnits.ToSimUnits(wheel.Width / 2f), 1f, theBike.Position + ConvertUnits.ToSimUnits(new Vector2(-bike.Width * 0.36f, bike.Height * 0.31f)));
            backWheel.BodyType = BodyType.Dynamic;
            backWheel.Restitution = 0f;
            backWheel.Friction = 20f;
            backWheel.CollisionCategories = Category.Cat2;
            backAxle = new RevoluteJoint(backWheel, backFork, Vector2.Zero, ConvertUnits.ToSimUnits(new Vector2(-(backfork.Width / 2f ) * 0.75f, backFork.Position.Y)));            

            angleBack = new RevoluteJoint(backFork, theBike, new Vector2(ConvertUnits.ToSimUnits(backfork.Width / 2f), backFork.Position.Y), ConvertUnits.ToSimUnits(new Vector2(0f, bike.Height * 0.42f)));
            angleBack.LowerLimit = 0.05f;
            angleBack.UpperLimit = 0f;
            angleBack.LimitEnabled = true;            

The problem is though, the LimitEnabled sometimes doesn't work. I've tried re-adjusting scales, lowering/increasing framerate, lowering/increasing gravity and a few other things, none of which solve my issue. When i was using a LineJoint, the physics of my bike would completely flip out in pretty much the same scenario where the RevoluteJoint goes past it's limits.

Can anyone offer any thoughts as to what i might be doing wrong? Or have a look at the full code? Or anything!?!?! It's driving me insane, it's sooo close to working but i can't quite get it there.


Dec 11, 2011 at 10:53 AM

Aiiiiahhh! Found the problem. Despite looking in depth at the samples a number of times, i skipped over this crutial line:


So setting the scale appropriately has made my life considerably better now :)