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 !
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)'."
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);
}