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

Ragdoll doesn't work

Topics: User Forum
Dec 14, 2009 at 3:27 AM
Edited Dec 14, 2009 at 3:28 AM

Hi guys, I'm new to this engine, and I've been having a few problems.  I've been trying to use the ragdoll demo.  I copied all the necessary parts from the SimpleSamples, and then modified it to work in my project.  This has just been to get a basis of where I could go from there.  I got the the ragdoll to display correctly, but now it's just stuck there in space.  I don't know if there's something I'm doing wrong or something simple I forgot to do (gravity)?  Thanks for the help!

Dec 14, 2009 at 2:41 PM
Edited Dec 14, 2009 at 2:42 PM

¿Did you set the gravity for the physics simulator?

Edit: I guess by your message you didn't :) Check the initialization code for the physics simulator in the demo.

Dec 15, 2009 at 12:35 AM
Edited Dec 15, 2009 at 12:35 AM

Thanks for the response.  This is in my Initialize() method. 

PhysicsSimulator = new PhysicsSimulator(new Vector2(100f));  //wasn't really sure what to do here

I gather that the new Vector2 is the gravity, but I don't know if that's right, or if I'm doing something else wrong.

Dec 15, 2009 at 10:39 AM

Should work like this:

PhysicsSimulator = new PhysicsSimulator(new Vector2(0, 100f));

The Vector2 indicates the gravity amount and in which direction; you can set the gravity "horizontal" to the right for example with new Vector2(100f, 0).

Also, I assume that your bodies and geoms are created using this same PhysicsSimulator: 

BodyFactory.Instance.CreateRectangleBody(PhysicsSimulator, ...
Jan 6, 2010 at 2:51 AM

Alright, I've spent the last while overhauling the framework of the game, making it work with the game state management sample (I assume it's not much different from Farsser's SimpleSamples structure).  After that, I checked to make sure that all of the PhysicsSimulators mentioned in the code were the same as in the ragdoll sample.  However, the ragdoll is once again stuck, and so am I.  If anyone could help, it would be greatly appreciated.  Thanks!

Jan 6, 2010 at 4:15 AM

Pete: I'm sure it's something simple, but it can be very challenging to debug without any source code at all. Please post up your project or email me a .rar or .zip of your project and I'd be happy to show you were your going wrong.

Jan 7, 2010 at 3:08 AM
Edited Jan 8, 2010 at 1:57 AM

Here it is:

Thanks a bunch for the help!


Jan 8, 2010 at 1:57 AM

Sorry, I couldn't email it to you because Gmail apparently doesn't accept .exe's in file attachments.  If you want just the plain code, I could take the .exe out, but the relevant code is on the pastebin.  Thanks a lot for the help!


Jan 8, 2010 at 11:42 PM

Hey guys, sorry to bug you again.  I was just wondering if anyone had a chance to look at the code?  It's in the URL above.  Thanks a lot!!

Jan 9, 2010 at 2:10 AM

I'm pretty sure I've found your problem. Nowhere in your code are you calling PhysicsSimulator.Update();

Place the following code at the top of the GameScreen.Update method and it  should work fine : 


_physicsSimulator.Update((float)gameTime.ElapsedGameTime.Milliseconds * .002



Jan 9, 2010 at 2:33 AM

LolrusPL AND Genbox, you guys are lifesavers!  Seriously, you two saved from yet more heartache.  Thanks guys.