Dynamic Bodies stick to platform that is moving away

Hi, Im trying to create a sloped platform that can move in any direction. Dynamic bodies that fall onto it should bounce or slide off. When the platform is moving upwards towards a falling object it seems to bounce or slide off correctly. But when the platform is moving away from the dynamic body it kind of "sticks" to the sloped platform.

Here is a video of what I mean:
http://www.youtube.com/watch?v=HzN3EuViuw8

I am moving the kinematic platform by using the SetLinearVelocity() method every frame.

What do I need to make the falling dynamic bodys react more realistically to my moving platform?

Here is some source snippets:

Code:

BODY CREATION:

// platform body
{
   b2BodyDef bd;
   bd.type = b2_kinematicBody;
   bd.angle = GROUND1_ANGLE;
   bd.position.Set(GROUND1_POS_X, GROUND1_POS_Y);
   ground = m_world->CreateBody(&bd);

   b2PolygonShape shape;
   shape.SetAsBox(GROUND1_SIZE_X / 2.0f, GROUND1_SIZE_Y / 2.0f);
   ground->CreateFixture(&shape, 0.0f);
}

// Square character
{
   b2BodyDef bd;
   bd.position.Set(-3.0f, 30.0f);
   bd.type = b2_dynamicBody;
   bd.fixedRotation = false;
   bd.allowSleep = false;

   b2Body* body = m_world->CreateBody(&bd);

   b2PolygonShape shape;
   shape.SetAsBox(0.5f, 0.5f);

   b2FixtureDef fd;
   fd.shape = &shape;
   fd.density = 20.0f;
   body->CreateFixture(&fd);
}


HERES HOW I MOVE THE PLATFORM IN MY STEP FUNCTION:

b2Vec2 veloc1(0.0f, 3.0f);
ground->SetLinearVelocity(veloc1);


You must have an older build. In the latest SVN code, this works fine:

Code:
class VerticalStack : public Test
{
public:
VerticalStack()
{
// platform body
{
   b2BodyDef bd;
   bd.type = b2_kinematicBody;
   bd.angle = b2_pi * 45.0f / 180.0f;;
   bd.position.Set(0.0f, 10.0f);
   m_ground = m_world->CreateBody(&bd);

   b2PolygonShape shape;
   shape.SetAsBox(4.0f, 0.5f);
   m_ground->CreateFixture(&shape, 0.0f);
}

// Square character
{
   b2BodyDef bd;
   bd.position.Set(0.0f, 30.0f);
   bd.type = b2_dynamicBody;
   bd.fixedRotation = false;
   bd.allowSleep = false;

   b2Body* body = m_world->CreateBody(&bd);

   b2PolygonShape shape;
   shape.SetAsBox(0.5f, 0.5f);

   b2FixtureDef fd;
   fd.shape = &shape;
   fd.density = 20.0f;
   body->CreateFixture(&fd);
}
}

   void Step(Settings* settings)
   {
      Test::Step(settings);

      b2Vec2 veloc1(0.0f, -3.0f);
      m_ground->SetLinearVelocity(veloc1);
   }

static Test* Create()
{
return new VerticalStack;
}

   b2Body* m_ground;
};
Hi Erin,

Just to make sure I had the most recent version, I clicked on "Downloads" from the box2d.org site which brought me to the google source site. Then I selected this featured download: "Box2D_v2.1.2.zip"

I ran cmake to create a Visual Studio 2008 *.sln file. Then I pasted your code in the VerticalStack.h class.

The falling dynamic body still doesnt bounce off the moving platform on my machine. It just sticks to it.

Any ideas?

Can anyone else try this and see what happens?

Thanks,
Paul


PS - The CMakeLists.txt file from google source may have a typo. The text: "set(BOX2D_VERSION 2.1.0)".....is that a typo?
You'll have to sync to the SVN trunk to get the kinematic body fix.
Thanks, syncing to SVN solved my problem.

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