misiek
18-08-2009 08:53:28
Hello,
I'm working on platform game, and have a problem with platform moving. My force and torque callback for platforms:
At the beginning of simulation it looks nice but bit by bit platform is shaking till it fall out of the OgreNewt world.
Sorry of my English!
I'm working on platform game, and have a problem with platform moving. My force and torque callback for platforms:
void CPlatform::forceAndTorqueCallback(OgreNewt::Body* body)
{
Real dt = mNewtWorld->getTimeStep();
Vector3 pos;
Quaternion orient;
body->getPositionOrientation(pos, orient);
// Vector3 CWaypoint::update(Real delta) returns the point where platform should be placed after delta time update
Vector3 ds = mWaypoint->update(dt) - pos; // that is translation vector
// finally set force
body->setForce( -body->getVelocity() * mPlatformMass /dt // to stop
+ 2 * ds * mPlatformMass / (dt * dt) ); // to translate
}
At the beginning of simulation it looks nice but bit by bit platform is shaking till it fall out of the OgreNewt world.
Sorry of my English!