Raycast vehicle not working

Post Reply
dorcsyful
Posts: 1
Joined: Sun Apr 25, 2021 6:08 pm

Raycast vehicle not working

Post by dorcsyful »

So I've been working on a project that involves implementing Bullet into Unreal Engine. So far it's been pretty successful: conversions and general movements are working perfectly. However I did run into an issue with the Raycast Vehicle: I followed the example that's on Github as best as I could (the calculations of the connection point were completely wrong and putting the suspension above 0.2 seems to push the wheels downwards by a lot), but it seems to partially sink into the ground. I say partially because the sinking stops at the connection point of the wheels to the chassis

Code: Select all

m_Raycaster = new btDefaultVehicleRaycaster(m_World);
    m_RVehicle = new btRaycastVehicle(m_Tuning,m_Chassis,m_Raycaster);
    m_Chassis->setActivationState(DISABLE_DEACTIVATION);
    AddAllWheels(a_Wheel, a_Transforms);
     m_World->addVehicle(m_RVehicle);

    btVector3 wheelDirectionCS0(0, 0,-1);
    //The axis which the wheel rotates arround
    btVector3 wheelAxleCS(0,1,0);
    btScalar wheelWidth = a_Wheel->getHalfHeight() * 2.f;
    btScalar wheelRadius = a_Wheel->getRadius();
    btVector3 trans = a_Transforms["FL"].getOrigin();
    btScalar suspensionRestLength = 0.2;
    btVector3 wheelConnectionPoint(trans.getY() + wheelRadius,trans.getZ() + wheelWidth,wheelRadius *2.f);

    //Adding front wheels
    m_RVehicle->addWheel(wheelConnectionPoint, wheelDirectionCS0, wheelAxleCS, suspensionRestLength,a_Wheel->getRadius(), m_Tuning, true);
    
    m_RVehicle->addWheel(wheelConnectionPoint * btVector3(1, -1, 1), wheelDirectionCS0, wheelAxleCS, suspensionRestLength, a_Wheel->getRadius(), m_Tuning, true);

    //Adds the rear wheels
    m_RVehicle->addWheel(wheelConnectionPoint * btVector3(-1, 1, 1), wheelDirectionCS0, wheelAxleCS, suspensionRestLength, a_Wheel->getRadius(), m_Tuning, false);
    // //
    m_RVehicle->addWheel(wheelConnectionPoint * btVector3(-1, -1, 1), wheelDirectionCS0, wheelAxleCS, suspensionRestLength, a_Wheel->getRadius(), m_Tuning, false);
    //
I'm not sure if this is related to me working with Unreal or if it's only on the Bullet side, but thanks in advance :)
Post Reply