- Home /
Question by
$$anonymous$$ · Oct 28, 2019 at 10:42 PM ·
audiosmoothcar physicspitchrealistic
car shifting smoothed. help!
Hello! I need some great help, I have the script of a car that the SOUND of it works with gear changes, but these are direct and rough, and are not smoothed as in Forza Horizon for example, I explain, the tone directly changes without any smoothing for example.
Here is the code:
//Shifting
EngineRPM = (WheelDI.rpm + WheelDD.rpm)/1.8f * GearRatio[CurrentGear];
ShiftGears();
//Audio
audio.pitch = Mathf.Abs(EngineRPM / MaxEngineRPM) + 0.2f ;
void ShiftGears (){
int AppropriateGear = CurrentGear;
if ( EngineRPM >= MaxEngineRPM ) {
for ( int i= 0; i < GearRatio.Length; i ++ ) {
if ( WheelDI.rpm * GearRatio[i] < MaxEngineRPM ) {
AppropriateGear = i;
break;
}
}
CurrentGear = AppropriateGear;
}
if ( EngineRPM <= MinEngineRPM ) {
AppropriateGear = CurrentGear;
for ( int j= GearRatio.Length-1; j >= 0; j -- ) {
if ( WheelDI.rpm * GearRatio[j] > MinEngineRPM ) {
AppropriateGear = j;
break;
}
}
CurrentGear = AppropriateGear;
}
}
I would be very grateful if you help me! Thanks!
Comment
Your answer
Follow this Question
Related Questions
Gear sound changes smoothed! 0 Answers
GetSpectrumData works only for 3 sec of microphone input 0 Answers
Is it possible to raise an audio sources pitch as an audio listener gets closer? 5 Answers
How can I change audio pitch without changing tempo? 1 Answer
sound is pitched down unexpectable 1 Answer