I create a slider contraint attached to world
Code: Select all
btTransform
axis.setIdentity();
axis.setRotation(btQuaternion(0, 0, 1, 1));
btSliderConstraint* constraint =
new btSliderConstraint(*rigid_body, axis, true);
constraint->setLowerLinLimit(-200);
constraint->setUpperLinLimit(200);
dynamic_world_->addConstraint(constraint, true);
Code: Select all
rigid_body->setLinearFactor(btVector3(0, 1, 0));
rigid_body->setAngularFactor(btVector3(0, 0, 0));
rigid_body->setDamping(0.999f, 1);
rigid_body->setActivationState(DISABLE_DEACTIVATION);
Code: Select all
btScalar velocity = 250;
if (keyboard->isKeyDown(OIS::KC_UP)) {
btVector3 position(0, velocity, 0);
rigid_body->setLinearVelocity(position);
} else if (keyboard->isKeyDown(OIS::KC_DOWN)) {
btVector3 position(0, -velocity, 0);
rigid_body->setLinearVelocity(position);
}
If the key remains pressed, the rigidbody will exceed the limit of the constraint(>-200) and
after a while will go back to the limit of the constraint(=-200).
This does not occur if the limit is set to
Code: Select all
constraint->setLowerLinLimit(-100);
constraint->setUpperLinLimit(100);
Does anyone have any idea why this happens?