[SOLVED] - btRaycastVehicle is bouncy

fsxfreak
Posts: 10
Joined: Mon Sep 03, 2012 12:09 am

[SOLVED] - btRaycastVehicle is bouncy

Post by fsxfreak »

In my implementation, my car bounces around wildly and the wheel spins uncontrollably. Is there any reason this happens?

Here is my code:

Code: Select all

    btTransform chassisTransform;
    chassisTransform.setIdentity();
    chassisTransform.setOrigin(GameState::ogreVecToBullet(mNode->getPosition()));

    mbtCar = createRigidBody(250, chassisTransform, mbtCar, mbtChassisShape);
    mbtCar->setActivationState(DISABLE_DEACTIVATION);

    mVehicleRaycaster = new btDefaultVehicleRaycaster(getGameState()->mDynamicsWorld);
    mVehicle = new btRaycastVehicle(mTuning, mbtCar, mVehicleRaycaster);
    mVehicle->setCoordinateSystem(0, 1, 2);

    float connectionHeight = 1.2f;
    float wheelWidth = mFL_Entity->getBoundingBox().getSize().x;
    float wheelRadius = mFL_Entity->getBoundingBox().getSize().y / 2;
    btVector3 wheelDirection(0, -1, 0);
    btVector3 wheelAxle(-1, 0, 0);
    btScalar suspensionRestLength(0.6);

    mVehicle->addWheel(btVector3(9.76, -4.37, 15.37), wheelDirection, wheelAxle, suspensionRestLength, wheelRadius, mTuning, true);
    mVehicle->addWheel(btVector3(-9.76, -4.37, 15.37), wheelDirection, wheelAxle, suspensionRestLength, wheelRadius, mTuning, true);
    mVehicle->addWheel(btVector3(9.76, -4.37, -15.37), wheelDirection, wheelAxle, suspensionRestLength, wheelRadius, mTuning, false);
    mVehicle->addWheel(btVector3(-9.76, -4.37, -15.37), wheelDirection, wheelAxle, suspensionRestLength, wheelRadius, mTuning, false);

    for (int iii = 0; iii < mVehicle->getNumWheels(); iii++)
    {
        btWheelInfo& wheelinfo = mVehicle->getWheelInfo(iii);
        wheelinfo.m_suspensionStiffness = 1.f;
        wheelinfo.m_wheelsDampingRelaxation = 2.3f;
        wheelinfo.m_wheelsDampingCompression = 4.4f;
        wheelinfo.m_frictionSlip = 100;
        wheelinfo.m_rollInfluence = 0.1f;
    }

    getGameState()->mDynamicsWorld->addVehicle(mVehicle);
I've taken examples from the Vehicle and Forklift demo.
Last edited by fsxfreak on Thu Sep 06, 2012 2:04 am, edited 2 times in total.
fsxfreak
Posts: 10
Joined: Mon Sep 03, 2012 12:09 am

Re: Problems with btRaycastCar

Post by fsxfreak »

Here's a video of what I'm describing.

http://www.youtube.com/watch?v=ijj4iOUkWvk&
fsxfreak
Posts: 10
Joined: Mon Sep 03, 2012 12:09 am

Re: Problems with btRaycastCar

Post by fsxfreak »

Solved my problem -

Code: Select all

mVehicle->updateVehicle(milliseconds / 1000);
instead of

Code: Select all

mVehicle->updateVehicle(1);
Should've known.