Gear shifting system for truck simulator

I am trying to create a truck simulator and currently I am stuck on how to implement the gear shift system.
With a car you would go from N -> 1 -> 2 -> 3 etc.
But for trucks it’s quite different.

This is a very simple basic diagram of the shifting pattern of an 18 speed transmission. This is the best way to understand the positioning of all 18 gears.
There are plenty of other gears in between, as all main gears have a high range and low range, so that the driver can split any of the gears, twice more.

How would I implement something like this where a player can decide which gear to go using Nvidia Physx?
Lets say when I am driving in gear 3 and I want to switch to 7L or something.


There are many ways to use the physx vehicle gearing system. Let’s see if one of these works out for you.

  1. Auto-gears: this won’t work because the logic is to increment or decrement one gear a time.

  2. 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.

  3. 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[10] > gearRatio[9]. 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,