I can’t do it((( and i can’t find the variables that may to pitch the volume of car engine. please help me
I’ve the solution :
function SendInput(Car : CarControl)
and add this line :
audio.pitch = Vector3.Dot(Car.rigidbody.velocity, Car.transform.forward);
It’s not really nice but… it’s work !
You should post your script here! But I’ll try to help you with my telepathic powers: I suppose the motor sound has audio.loop set (or Loop checked at Inspector), and that you have a variable indicating the motor rotation - let’s call it rpm. To change the sound pitch, you must modify the variable audio.pitch. Its basic value is 1, what indicates the natural pitch of the sound; this variable accepts anything > 0, but for values too lower or higher than 1 the sound may become too weird, so it’s better to keep it inside the range 0.5 (low rotation) to 2.5 (high rotation). You can thus update the pitch according to the rpm variable with something like this:
audio.pitch = 0.5 + 2.0 * (rpm - minRpm)/(maxRpm-minRpm);
This code will set audio.pitch to 0.5 when rpm == minRpm and 2.5 when rpm == maxRpm. If this can’t help solving your case, please post your script here.
EDITED: Well, your scripts are very complex. I couldn’t find information about the motor rotation, but suppose you may know where to find it - or at least something related to the vehicle speed. You should also get a motor sound edited to run continuously in loop mode (a sound that seems continuous when repeated). If you don’t have any, download this sound - it’s a V8 motor idling, and may serve as a starting point to develop your sound effects.
Import the sound to your project, add an AudioSource to your car, and set its Clip property to this sound - remember to check the Loop property too. With this setting, your car will have a continuous and constant motor sound. To make it follow the motor rotation, use the equation showed above.