There are many ways to use the physx vehicle gearing system. Let’s see if one of these works out for you.
Auto-gears: this won’t work because the logic is to increment or decrement one gear a time.
Gear-up/gear-down pressed: again, this won’t work because the logic is to increment or decrement one gear at a time as a reponse to a button press.
Call PxVehicleDriveDynData::startGearChange(targetGear) (an alternative is to call PxVehicleDriveDynData::setTargetGear). This requires that you have knowledge of the target gear eg 7L and its gearing ratio.
I think method 3) will work for you with a little bit of programming effort. I’ll just talk you through the steps.
a) PhysX expects that each gear ratio is smaller than the previous ie gearRatio > gearRatio. This reflects the typical use case where the car starts in a low gear and moves linearly through the gears as it accelerates. Your gear indexing might not match this rule but it is still possible to sort your gear ratios and create a mapping between your gear indices and the sorted indices. The gear ratios can then be filled out in the usual way.
b) Call startGearChange(targetGear) as required using the mapping between your gear indices and the physx gear indices eg gear 7L might map to the gear ratio with gear index 14 so you would call startGearChange(14).
c) Check that the car isn’t half-way through a gear change before calling startGearChange.
Putting this all together, we end up with something like:
//List of truck gears.
//Mapping between truck gears and gear list sorted by gear ratio
unsigned int mappedGears=
unsigned int targetGear = e7L;
if(myVehicle.mDriveDynData.getTargetGear() == myVehicle.mDriveDynData.getCurrentGear())
Hope this works out,