- Home /
Question by
EliteHedgehog56 · Mar 02, 2018 at 04:05 AM ·
audiosourceaudioclippitch
script changes audio pitch
I have a script for my racing game that starts the race after 3 seconds(enables the car controller script after 3 seconds), I have an audio source component attached to it that plays a beep sound effect every second before starting the race, however when the countdown reaches zero the pitch of the sound is automatically changed. Is this intentional or is there something wrong with my script?
here's the script:
public class RaceStart : MonoBehaviour {
public PlayerCar scriptPlayerCar;
void Start()
{
scriptPlayerCar = GetComponent<PlayerCar> ();
scriptPlayerCar.enabled = false;
StartCoroutine(Countdown(3));
}
IEnumerator Countdown(int seconds)
{
int count = seconds;
while (count > 0) {
// display something...
yield return new WaitForSeconds(1);
count --;
}
// count down is finished...
StartGame();
}
void StartGame()
{
scriptPlayerCar.enabled = true;
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612153749im_/https://answers.unity.com/themes/thub/images/avi.jpg)