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:
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);
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);