seesaw platform problem
Posted: Mon Jul 02, 2012 5:15 pm
I have a bar completely across the screen and it moves in a seesaw fashion 10 degrees either way moving in 0.1 degree steps. The bar is a rogue body and I change the angle.
The center point of the bar is in the middle of the screen.
A ball sits on top of this bar and will roll from left to right and vice versa when it tilts the other way.
It is all working apart from the ball will looks a little off the line by about 2-4 pixels in the air when it tilt downward like it not able to catch up the falling momentum of the see-saw.
// m_floor_angle value ranges from -10.0f to 10.0f
I've tried setting m_moveableFloorBody->w to a value other than 0.0f and it makes it worst depending on which side of the seesaw the ball currently sits on.
I've tried various other things such as setting the ball velocity to make it catch up the falling see-saw but it doesn't seem to work well.
Is there a solution to this?
The center point of the bar is in the middle of the screen.
A ball sits on top of this bar and will roll from left to right and vice versa when it tilts the other way.
It is all working apart from the ball will looks a little off the line by about 2-4 pixels in the air when it tilt downward like it not able to catch up the falling momentum of the see-saw.
// m_floor_angle value ranges from -10.0f to 10.0f
Code: Select all
cpFloat floorAngle = m_floor_angle < 0 ? 360 + m_floor_angle : m_floor_angle;
cpFloat a = fmod(floorAngle * M_PI / 180.0f, 360);
m_moveableFloorBody->w = 0.0f;
cpBodySetAngle(m_moveableFloorBody, a);
cpSpaceReindexShapesForBody(m_space, m_moveableFloorBody);
I've tried various other things such as setting the ball velocity to make it catch up the falling see-saw but it doesn't seem to work well.
Is there a solution to this?