using System.Collections; using System.Collections.Generic; using UnityEngine; public class StopSound : MonoBehaviour { [SerializeField] private PlaySound _playSound; private void OnTriggerEnter(Collider col) { if (col.gameObject.tag == "Player" && !_playSound.ClipStopped) { StopThisSound(); } } public void StopThisSound() { _playSound.ClipStopped = true; } public void StopThisSoundImmediately() { _playSound.audioSource.Stop(); _playSound.ClipStopped = true; } }