How to set pitch for a car engine's sound ?

Hi all,

I’m working on a buses simulator game…
My game work perfectly but i’ve a problem with the sound of the bus… I don’t know how to vary the pitch of the engine’s sound when I incrase or decrase the speed of the bus !

Thank at advance for your replies
Chris

You can access the pitch easily enough (here). As for when, if your car’s controls are already done, it won’t be hard to find out !

Ok ! Now, I've an other problem with the sound....

So, in my game, I want to play a sound when I press "up" key; to stop it and replace it when I release the "up" key

There's my code : var iddle: AudioClip;

var acceleration: AudioClip;

var ralenti: AudioClip;

function Update() {

if (Input.GetKeyDown ("up"))

    audio.PlayOneShot(acceleration);

if (Input.GetKeyUp ("up"))

    audio.Stop (acceleration);

}

But when I start the game, unity say "Assets/VelocitySound.js(15,20): BCE0017: The best overload for the method 'UnityEngine.AudioSource.Stop()' is not compatible with the argument list '(UnityEngine.AudioClip)'."

?? Thank at advance for you're help !

Ok ! So I’ve fix my problem… the good code is:

var iddle: AudioClip;

var acceleration: AudioClip;

var ralenti: AudioClip;

var rec: AudioClip;

var radio: AudioClip;





function Update() {



if (Input.GetKeyDown ("up"))

	audio.PlayOneShot(acceleration);





if (Input.GetKeyUp ("up"))

	audio.Pause();

	

if (Input.GetKeyDown ("down"))

	audio.PlayOneShot(rec);

	

if (Input.GetKeyUp ("down"))

	audio.Pause();

	

if (Input.GetKeyDown ("o"))

	audio.PlayOneShot(radio);

}

Thank Berenger for u’re help !