RevoluteJoint not working (body gets stuck)

Topics: User Forum
Feb 27, 2011 at 10:59 PM

I've been trying to get this fixed for a while, but can't figure it out. It was working before I started scaling stuff down (metric instead of pixels) and I already tried increasing things like masses to previous values, but nothing seems to work.

The body appears above (although i decreased the y-coords) the end of the rope and gets stuck. It won't move at all when i apply forces/torques. I also tried using a non-fixed revolute joint with the same result.

Here's the important code:

 


f = FixtureFactory.CreateRectangle(Game.world, ConvertUnits.ToSimUnits(sprite.Width), ConvertUnits.ToSimUnits(sprite.Height), 1f, new Vector2(0, 0));
f.Body.BodyType = BodyType.Dynamic;
f.Body.Inertia = float.MaxValue;
f.Restitution = 0f;
f.Body.Mass = .15f;
f.AfterCollision += new AfterCollisionEventHandler(afterCollision);
center = FixtureFactory.CreateRectangle(Game.world, 10, 10, 1, f.Body.Position - ConvertUnits.ToSimUnits(new Vector2(0, 100)));
center.Body.BodyType = BodyType.Dynamic;
j = JointFactory.CreateFixedRevoluteJoint(Game.world, f.Body, f.Body.Position, center.Body.Position);
j.Enabled = true;
center.Body.ApplyTorque(10f);

Feb 28, 2011 at 6:39 PM

I would suggest implementing the DebugView so that you would get a clear picture of how the bodies and joints are aligned.