// Start is called before the first frame update void Start() { //music = GameObject.FindGameObjectWithTag("Music"); dyn = GameObject.FindGameObjectWithTag("Player").GetComponent <DynamicMusic>(); ambiance = GameObject.FindGameObjectWithTag("AMusic"); aAnim = GameObject.FindGameObjectWithTag("AMusic").GetComponent <Animator>(); }
// Use this for initialization void Start() { //Find dynamic music object music = GameObject.FindGameObjectWithTag("Music").GetComponent <DynamicMusic>(); volume2D = music.GetVolume(false); volume3D = music.GetVolume(true); //List of audio sources in relevant speakers sources = new List <AudioSource>(); foreach (GameObject s in speakersOn) { sources.Add(s.GetComponent <AudioSource>()); } }
private static void Reset(float x, float y, float z, int retries, float time, int died) { PlayerPrefs.SetInt("retries", retries); PlayerPrefs.SetFloat("time", time); PlayerPrefs.SetFloat("resetPosx", x - 5); PlayerPrefs.SetFloat("resetPosy", y); PlayerPrefs.SetFloat("resetPosz", z); PlayerPrefs.SetInt("died", died); PlayerPrefs.Save(); SceneManager.LoadScene(0); DynamicMusic m = GameObject.FindGameObjectWithTag("Music").GetComponent <DynamicMusic>(); float musicTime = m.gameObject.GetComponent <AudioSource>().time; m.ResetSpeakers(musicTime); }
//Set up speakers when player touches the trigger void SetSpeakers() { sources = new List <AudioSource>(); //Clear sources in case resetting game messes it up sources.Clear(); foreach (GameObject s in speakersOn) { sources.Add(s.GetComponent <AudioSource>()); } //Mute all other speakers in scene using dynamic music object music = GameObject.FindGameObjectWithTag("Music").GetComponent <DynamicMusic>(); music.MuteAll(); //Set relevant speakers on with appropriate spatialisation foreach (AudioSource s in sources) { SetSpatialize(s, music3D); } }