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

Problem character physics

Topics: Developer Forum, User Forum
Aug 16, 2010 at 9:27 PM
Edited Aug 16, 2010 at 10:57 PM

EDIT 2: I have fixed it with a RevoluteJoint, I'll leave this here in case anyone has a better suggestion.


Hi, I'm trying to do the box+wheel technique for character physics suggested by RobertDodd in this topic:

I followed his instructions, however I'm having a problem where when the wheel moves to the right (or left) the box does not, it simply falls to the left and then gets dragged by the ball. I have set the fixed angle on the box however this does not stop the PinJoint from "rotating". This is what my (very rough) code looks like:


	public Character(Texture2D sprite, PhysicsSimulator world)
            this.sprite = sprite;
   = world;

            torso = BodyFactory.Instance.CreateRectangleBody(world, width, height / 2, 1.0f);
            torso.Position = new Vector2(300, 300);

            feet = BodyFactory.Instance.CreateCircleBody(world, width / 2, 1.0f);
            feet.Position = new Vector2(300, 300 + height / 2);

            Geom torsoGeom = GeomFactory.Instance.CreateRectangleGeom(world, torso, width, height / 2);

            Geom feetGeom = GeomFactory.Instance.CreateCircleGeom(world, feet, width / 2, 32);
            feetGeom.FrictionCoefficient = 10;

            feetGeom.CollisionGroup = 1;
            torsoGeom.CollisionGroup = 1;

            fixedAngleJoint = JointFactory.Instance.CreateFixedAngleJoint(world, torso);

            pinJoint = new PinJoint();
            pinJoint.Body1 = torso;
            pinJoint.Body2 = feet;
            pinJoint.TargetDistance = 50;

I made it so that the box and wheel don't collide because if they do then the collision creates friction and makes the movement very irregular. Basically my problem is that when the wheel moves the box does not until it falls and gets dragged, it won't stay on top of the wheel. Any ideas?


EDIT: I'm using Farseer Physics 2.1.3 in case it matters.