private void OnTriggerExit(Collider other) { MusicChanger musicChanger = other.gameObject.GetComponentInChildren <MusicChanger>(); //print("Left collision with " + other.gameObject.name); if (musicChanger == lastInteractedMusicChanger) { lastInteractedMusicChanger = null; // reset the node so we can talk to it again } }
private void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } DontDestroyOnLoad(this.gameObject); }
private void OnTriggerEnter(Collider other) { MusicChanger musicChanger = other.gameObject.GetComponent <MusicChanger>(); //print("Collided with " + other.gameObject.name); if (musicChanger != null && musicChanger != lastInteractedMusicChanger) { if (musicChanger.ShouldChange()) { // then try talking with it! musicManager.PlayMusicClip(musicChanger.clip); musicChanger.ChangedMusic(); lastInteractedMusicChanger = musicChanger; } } }