'Carrying' objects on a moving platform (static body)

Topics: Developer Forum
Feb 24, 2009 at 10:43 PM
Hey All - I'm fairly new to Farseer, but love what I see so far.

I'm running into a small problem and not sure what the best/easiest way to solve it is. I have a moving platform (consisting of a static body being manually moved between locations), which is intended to 'carry' other non-static physics bodies around the level. Unfortunately, when the platform moves horizontally all the bodies slide off - as expected vertical platform movement works fine. I've played around with the platform's Friction, LinearDragCoefficient, and MomentOfInertia to no avail (perhaps caused by an improper balance of each). The bodies must be able to fall of the platform if an external force is applied to them (collision, platform rotation, platform acceleration, etc.)

Am I messing with the proper variables? Is this something best achieved using a different method such as a joint? Am I potentially missing a variable on the non-static physic bodies?

Any hints/suggestions would be appreciated!
Feb 25, 2009 at 2:28 AM
If you're using the FrictionType.Minimum then cranking up the friction extremely high on the platform would have no effect. if changing the FrictionType doesn't help, try adding small "lips" on either side so that the objects don't slide off but can be pushed off/etc.
Feb 27, 2009 at 6:26 PM
Thanks for the quick reply - Marking the PhysicsSimulator.FrictionType as FrictionType.Average still results in the same behaviour. For testing purposes, all the bodies and the platform's Geom.FrictionCoefficient were set to 100. Strangely, the friction seems to work when a body is moved onto the platform (which forces the bodies velocity to decrease quickly), and also requires a greater force to accelerate the body off the platform. However, when the static platform is moved, it appears no friction is applied to the bodies as they remain in the their same initial position and 'slide' off of the platform.

Unfortunately the lip solution isn't an ideal solution for what I'm trying to do as the platforms are intended to be game elements that user-controlled characters will use to travel to various portions of levels.

Again, any hints/suggestions would be appreciated!
Feb 27, 2009 at 8:23 PM
It appears I've tracked down the issue - the platform's position is being explicitly set as opposed to using its velocity or an external force. It is done this way to allow for multiple types of interpolation between points (cubic, linear, etc.) and to ensure that nothing interferes with the platform throughout the interpolation process.

Is there an alternative method to achieve what I'm trying to do?
Is there any way to explicity set the platform position and still have it resolve friction properly?
Feb 27, 2009 at 8:40 PM
Let me explain how it works:

When you are moving your static body manually, all the different kinds of physicsrelated variables does not get calculated. Most importantly the linear velocity of the body does not get calculated.
Whenever a geometry is resting on top of the moving platform, it will slide off. Just the same as if there were no friction between the platform and geometry. There are several ways of "fixing" this. It all depends on how you would like the platform to react to forces.

Should it stop when something is in the way? should it accelerate if it moves down hill? lot's of relevant questions when it comes to getting the right solution.

The simplest way of getting this to work is to calculate the velocity of the moving platform and set it yourself. This could create some unwanted behavior because it would create somewhat realistic movements of the character.
Another way of doing it is by moving all geometries the same amount as the platform, when they collide with the platform. Essentially you detect when something is on the platform and move it.