Search Unity

Car audio, gear shifting and RPM, How?

Discussion in 'Scripting' started by SamohtVII, Apr 18, 2019.

  1. SamohtVII


    Jun 30, 2014
    I have a basic car controller (here: and i need to add some audio into it. Can anyone explain how car audio works in terms of rpm, pitch, gear changing etc?

    I understand higher rpm = higher pitch?

    And how, with a basic car controller, do I simulate a gear change and in turn audio?

    I have the basic idea of
    Code (CSharp):
    1. gear = 1
    2. if(speed > 20 && speed < 50) gear = 2
    3. else if (speed > 50 && speed < 70) gear = 3
    4. etc.
    Then based on gear and where the speed is between min and max set the pitch.
    So if we are at 30kph we are in gear 2's pitch range and we are at about 20% of gear 2's total (Between 20 and 50).

    If I am way off i'd love some explanation and correction.

  2. SparrowsNest


    Apr 6, 2017
    the pitch should be relative to the RPM of the engine, not the speed, the sound you get from speed is from the tire friction to whatever its driving on and noise from air turbulence.

    I'm not sure what do you mean "how car audio works", but yes,
    is basically what applies.
  3. csofranz


    Apr 29, 2017
    I agree with Sparrows' and would add the following (Sparrow mentioned ot as an aside):

    1. the engine sound (pitch) is a function of rpm - higher rpm --> higher pitch. This simulates the Audio generated from the engine
    2. Add a rumbling/white noise sound source that simulate the noise generated by wind and tires. This only increases in pitch (slightly) and volume by the car's speed.

    So you'll have at least two sound sources that create the sound of your car.