// Create the needed AudioSources void Awake() { car = transform.GetComponent<Car_CSharp> (); DVolume *= 0.4f; EVolume *= 0.4f; FVolume *= 0.4f; KVolume *= 0.7f; LVolume *= 0.4f; windVolume *= 0.4f; DAudio = gameObject.AddComponent<AudioSource> (); DAudio.loop = true; DAudio.clip = D; DAudio.volume = DVolume; DAudio.Play (); EAudio = gameObject.AddComponent<AudioSource> (); EAudio.loop = true; EAudio.clip = E; EAudio.volume = EVolume; EAudio.Play (); FAudio = gameObject.AddComponent<AudioSource> (); FAudio.loop = true; FAudio.clip = F; FAudio.volume = FVolume; FAudio.Play (); KAudio = gameObject.AddComponent<AudioSource> (); KAudio.loop = true; KAudio.clip = K; KAudio.volume = KVolume; KAudio.Play (); LAudio = gameObject.AddComponent<AudioSource> (); LAudio.loop = true; LAudio.clip = L; LAudio.volume = LVolume; LAudio.Play (); windAudio = gameObject.AddComponent<AudioSource> (); windAudio.loop = true; windAudio.clip = wind; windAudio.volume = windVolume; windAudio.Play (); tunnelAudio = gameObject.AddComponent<AudioSource> (); tunnelAudio.loop = true; tunnelAudio.clip = tunnelSound; // tunnelAudio.maxVolume = tunnelVolume; tunnelAudio.volume = tunnelVolume; skidAudio = gameObject.AddComponent<AudioSource> (); skidAudio.loop = true; skidAudio.clip = skidSound; skidAudio.volume = 0.0f; skidAudio.Play (); carAudio = gameObject.AddComponent<AudioSource> (); carAudio.loop = false; carAudio.playOnAwake = false; carAudio.Stop (); crashTime = Mathf.Max (crashLowSpeedSound.length, crashHighSpeedSound.length); soundsSet = false; idleFadeSpeedDiff = idleFadeStopSpeed - idleFadeStartSpeed; speedFadeSpeedDiff = speedFadeStopSpeed - speedFadeStartSpeed; backgroundMusic = gameObject.AddComponent<AudioSource> (); backgroundMusic.loop = true; backgroundMusic.clip = BackgroundMusic; // backgroundMusic.maxVolume = BackgroundMusicVolume; // backgroundMusic.minVolume = BackgroundMusicVolume; backgroundMusic.volume = BackgroundMusicVolume; backgroundMusic.Play (); }
// Use this for initialization void Start() { sound = transform.root.GetComponent<SoundController_CSharp>(); car = GetComponent<Car_CSharp>(); }