btRaycastVehicle roll-over on sharper turns
Posted: Wed May 30, 2018 12:25 pm
Hi, I have a problem with btRaycastVehicle. Whenever there is a sharp turn left or right, my vehicle rolls over the roof and spins a few times, even when the speed is not that high. I know that it's probably more or less how the vehicle would react in a real world, but I'm working on an arcade game and would like to achieve a slightly different behaviour. I would like the vehicle to slip / drift when there is a sharper turn but not roll over the roof. Could you give me some insights on which parameters should I adjust in order to achieve it ? Currently I have the following setup:
Code: Select all
btScalar chassisMass(1000.f);
btVector3 chassisInertia(0.0f, 0.0f, 0.0f);
btCollisionShape* chassisShape = new btBoxShape(btVector3(0.5f, 0.3f, 1.0f));
tuning.m_suspensionStiffness = 20.f;
tuning.m_suspensionDamping = 2.3f;
tuning.m_suspensionCompression = 4.4f;
tuning.m_maxSuspensionForce = 16000;
chassisRigidBody->setDamping(0.2f, 0.3f);
groundRigidBody->setFriction(2.f);
btVector3 wheelDirection(0.0f, -1.0f, 0.0f);
btVector3 wheelAxis(-1.0f, 0.0f, 0.0f);
btScalar suspensionRestLength(.1f);
btScalar wheelRadius(0.5f);
vehicle->addWheel(btVector3(-0.5f, 0.f, -1.0f), wheelDirection, wheelAxis, suspensionRestLength, wheelRadius, tuning, true);
vehicle->addWheel(btVector3( 0.5f, 0.f, -1.0f), wheelDirection, wheelAxis, suspensionRestLength, wheelRadius, tuning, true);
vehicle->addWheel(btVector3(-0.5f, 0.f, 1.0f), wheelDirection, wheelAxis, suspensionRestLength, wheelRadius, tuning, false);
vehicle->addWheel(btVector3( 0.5f, 0.f, 1.0f), wheelDirection, wheelAxis, suspensionRestLength, wheelRadius, tuning, false);