public override void Play(string name) { DynamicSound s = GetDynamicSound(name); s.ConfigureAudioSource(audioSource); if (!audioSource.isPlaying) { audioSource.Play(); } CheckIfEnemyIsInRange(s); }
public override void Play(string name) { DynamicSound s = GetDynamicSound(name); if (s == null) { return; } s.ConfigureAudioSource(audioSource); if (!audioSource.loop) { audioSource.Play(); } else if (!audioSource.isPlaying) { audioSource.Play(); } CheckIfEnemyIsInRange(s); }
public void Play2DClipAtPoint(string name, Vector2 position) { // Create a temporary audio source object GameObject tempAudioSource = new GameObject("TempAudio"); // Set Position tempAudioSource.transform.position = position; AudioSource audioSource = tempAudioSource.AddComponent <AudioSource>(); DynamicSound s = GetDynamicSound(name); s.ConfigureAudioSource(audioSource); CheckIfEnemyIsInRange(s); if (!audioSource.loop || !audioSource.isPlaying) { audioSource.Play(); } // Set it to self destroy Destroy(tempAudioSource, s.clip.length); }
public void SetupAudioSource(string name) { DynamicSound s = GetDynamicSound(name); s.ConfigureAudioSource(audioSource); }