I have to change the position of a raycast vehicle after it has been created and added to the dynamics world. I tried the following code:
Code: Select all
btTransform trans;
trans.setOrigin(btVector3(m_reset_pos.xyz[0],
m_reset_pos.xyz[1],
m_reset_pos.xyz[2]+0.5*m_kart_height));
m_kart_body->setCenterOfMassTransform(trans);
Problem is, that this doesn't really work - at the first stepSimulation() after the call, the kart will be flipped around (the X-axis), ending up with the wheels up in the air, and the front wheels at the back

Additionally, the manual states that the position of a dynamic rigid body should not be changed by the user

Unfortuantely, I have to change the vehicle position (when restarting a race) - otherwise I have to do quite a bit of restructuring, making the resulting code much harder to understand (destroying and recreating expensive objects).
Is there any way of doing changing a vehicle position 'correctly'? What about removing the rigid body from the dynamics world, changing the transformation, and adding it again? If this is correct, what about the vehicle which was added to the world as well??
Any recommendations appreciated!
Joerg