Reset vehicle

makke4ever

25-05-2011 14:59:48

Hi,

I am implementing a reset function for my race game, but this seems not as easy as I thought.

The first way I tried was by calling the setPosition() function of the wheeledRigidBody, but this did not work as it should.

Another way I tried was by deleting the entire vehicle and just creating it back, but when I do this, the program crashes in the stepSimulation() function of OgreBulletCollisions::CollisionsWorld. The exact bullet function that crashes is btDiscreteDynamicsWorld::updateActions(). I have looked at the constructor en destructor of RaycastVehicle, but the destructor does not delete any of the pointers created in the constructor. Could this be the source of my problem?

Can someone please help me?

uberkoch

02-09-2011 14:30:41

I just stumbled upon your question, i had the same problem when deleting vehicles. I tracked it down to the fact, that the ActionInterface is not removed in the destructor of RayCastVehicle.
I added the following to my own destructor and deleting worked like a charm

m_world->getBulletDynamicsWorld()->removeAction(m_vehicle->getBulletActionInterface());


I don't know if it helps you or you even need it anymore, but maybe other people run into the same problem.

JohnBoyManbullet

03-09-2011 19:41:30

I see where you said set position , you cant use that if your using bullet





transform.setIdentity();

//Ogre::Quaternion quat= delta;
transform.setOrigin( btVector3(BtOgre::Convert::toBullet( position + Ogre::Vector3(0,60,0) )) );
transform.setRotation(BtOgre::Convert::toBullet(quat));


body5->setWorldTransform(tranfrom);

body5->activate(true);


if you just wana reset position use that