Code: Select all
body->activate(true);
btMotionState* ms = body->getMotionState();
btTransform tf;
ms->getWorldTransform(tf);
tf.setOrigin(btVector3(x, y, z));
ms->setWorldTransform(tf);

How to manually change position of dynamic object

Code: Select all
body->activate(true);
btMotionState* ms = body->getMotionState();
btTransform tf;
ms->getWorldTransform(tf);
tf.setOrigin(btVector3(x, y, z));
ms->setWorldTransform(tf);


 
														Code: Select all
virtual void getWorldTransform(btTransform &worldTrans) const
		{
			worldTrans.setRotation(toBt(mSceneNode->_getDerivedOrientation()));
			worldTrans.setOrigin(toBt(mSceneNode->_getDerivedPosition()));
		}
		virtual void setWorldTransform(const btTransform &worldTrans)
		{
			const btQuaternion &rot = worldTrans.getRotation();
			mSceneNode ->setOrientation(rot.w(), rot.x(), rot.y(), rot.z());
			const btVector3 &pos = worldTrans.getOrigin();
			mSceneNode ->setPosition(pos.x(), pos.y(), pos.z());
		}

 
														Code: Select all
    virtual void YourMotionState::setWorldTransform(const btTransform &worldTrans)
    {
         const btQuaternion &rot = worldTrans.getRotation();
         mSceneNode ->setOrientation(rot.w(), rot.x(), rot.y(), rot.z());
         const btVector3 &pos = worldTrans.getOrigin();
         mSceneNode ->setPosition(pos.x(), pos.y(), pos.z());
         mBody->setWorldTransform(worldTrans);
    }
Thanks marios. It shoud be done as you said. Not via motionstate.marios wrote:just use body->setWorldTransform() not motionstate->setWorldTransform(tf);
Code: Select all
mBody->setWorldTransform(worldTrans);