Creating vehicle acceleration with gear support
I am trying to figure out a good way to create vehicle acceleration with gear support. Basically:
There is RPM (goes from 0 to 6000); There's actual car speed; There's HORSE_POWER (which is just to make car faster or slower in acceleration) There are 6 gears (from -1 to 5, neutral is irrelevant); User's input is a variable:
gaswhich is -1, 0 or 1When on neutral (gear==0) and holding gas (gas==1) the car switches to 1st gear. ^ This is the easy part that is done
Now, i need to make so that it accelerates, and when it hits 3000 RPM it switches to the next gear and so on up until it hits the 5th gear and then it just caps at 6K RPM.
Obviously, the car should also decelerate when nothing is pressed or slow down more rapidly when breaks are hit.
The part i struggle with is to make so that the car accelerates slower as the gears shift forward (including that it should go from 3000 to 2000 when changing gear)