Simulating a moving platform

Hi,

I'm trying to have a platform that is moving up and down, to allow other objects to reach higher parts of the b2world.
I tried having a body without mass (my platform) that I'm moving up and down by calling the SetXForm method with small 'y' increases. This was only to allow me to stop the platform in the exact point I need it to be.

Unfortunately, by moving like this, my platform seems to ignore whatever objects are over it, just moving without dragging them up with it.

There has to be a easy way of simulating a moving platform with box2d? Maybe a body with a motor or something?

If someone knows of the a good way of doing it, please help!

Thanks!
João
As long as you keep your y small, don't let two static shapes overlap and don't worry about friction, your technique should work. But using a joint is preferred as it interacts better with the rest of the objects. Use a prismatic joint, and a heavy but non-static body.
Thanks Boris, I'll try that!
I'm not sure if SetXForm would wake up the body (ApplyForce/Impulse on the other hand would). If both bodies are asleep, they will most likely be skipped by collision detection. Calling b2Body::WakeUp when you call b2Body::SetXForm should be enough to fix your problem.

Original thread: https://box2d.org/forum/viewtopic.php?t=3140