I use a dynamic world to move bullets and detect collisions inside my space-rts. My internale game-tick is 100 ms and I'm calling
Code: Select all
mDynamicsWorld->stepSimulation(mTimer->getMilliseconds() / 1000.0f, 60);
mTimer->reset();The motionstate for the bullets looks like that:
Code: Select all
BulletMotionState::BulletMotionState(DataStructures::BulletData * bulletData)
{
mBillboard = 0;
mBulletData = bulletData;
mTransform.setOrigin(btVector3(bulletData->origin().x, bulletData->origin().y, bulletData->origin().z));
mTimer = new Ogre::Timer();
}
BulletMotionState::~BulletMotionState(void)
{
}
void BulletMotionState::getWorldTransform(btTransform &worldTrans) const
{
worldTrans.setIdentity();
worldTrans.setOrigin(mTransform.getOrigin());
}
void BulletMotionState::setWorldTransform(const btTransform &worldTrans)
{
if(mBillboard)
{
btVector3 pos = worldTrans.getOrigin();
pos = pos * SCENE_SCALE;
std::cout << "\ntimer: " << Tools::IntToString((int)mTimer->getMilliseconds()) << " Pos: " << Tools::FloatToString(pos.x()) << ", " << Tools::FloatToString(pos.z());
mTimer->reset();
mBillboard->setPosition(pos.x(), pos.y(), pos.z());
}
}I have an Ogre::Timer to see, how many ms are gone between two position-changes of the bullet and to debug my problem, I make a console-output. It looks like that:
Code: Select all
timer: 103 Pos: 249.856, 7.22558
timer: 0 Pos: 249.858, 7.32275
timer: 0 Pos: 249.861, 7.41993
timer: 0 Pos: 249.864, 7.51711
timer: 0 Pos: 249.867, 7.61429
timer: 0 Pos: 249.87, 7.71146
timer: 103 Pos: 249.871, 7.72896
timer: 0 Pos: 249.874, 7.82613
timer: 0 Pos: 249.877, 7.92331
timer: 0 Pos: 249.88, 8.02049
timer: 0 Pos: 249.883, 8.11767
timer: 0 Pos: 249.885, 8.21484
timer: 0 Pos: 249.888, 8.31202
timer: 101 Pos: 249.892, 8.41503
timer: 0 Pos: 249.894, 8.51221
timer: 0 Pos: 249.897, 8.60939
timer: 0 Pos: 249.9, 8.70656
timer: 0 Pos: 249.903, 8.80374
timer: 0 Pos: 249.906, 8.90092
timer: 108 Pos: 249.911, 9.04474I hope you can help me with this problem, because I don't see the mistake I make here ...
Thanks in advance
Peter