Mass problem with usercontrols

Nov 23, 2010 at 3:53 PM

I have a number of user controls that get added programatically with AddPhysicsBodyForCanvasWithBehaviors.  They work fine, but the moment I add mass to any of them, and the objects get stacked, they keep shuffling about and will not sit on top of each other.  Ive tried adjusting the masses and I just can't get them to sit still unless i revert the masses back to 0.

I have double checked the boundaries to ensure they are set correctly, which they are.

Sorry, my second posting today ;)

Thanks again for the great library!

Nov 25, 2010 at 1:48 PM

Hi Mike,

With lots of stacking bodies the key is to have the Bodies Rest. They will rest as long as other objects around them are not moving past a threshold. If you need to , you can adjust this threshold in the Farseer code, I think it is in the Settings file.

From what I've seen this can be due to World Size in relation to the Body size. The Physics Helper makes a world size automatically for you, based on the screen size of you main Game Canvas (the one with the PhysicsControllerBehavior). This defaults to 800x480 if no size is given to the Canvas, so you may want to make sure you explicity set the height and width of your Game canvas.

Also did you take a look at the Demo that ships with the source code (you can get it here with the latest ChangeSet download - It has stacking boxes that seem to behave OK and go into Rest mode.

Nov 25, 2010 at 2:18 PM

Hi Andy,

Thanks for the reply, The demo blocks do not have any mass either so I didn't really look into them any further.

I will try and play with the rest threshold to see if that sorts it out, i'll post here if it does.