using UnityEngine; using System.Collections; public class EffectSoundShoot : MonoBehaviour { private AudioSource audioSource; private float startTime; public float duration = float.MaxValue; void Start() { audioSource = GetComponent(); startTime = GameTime.time; } // Update is called once per frame void FixedUpdate () { if(audioSource == null || !audioSource.isPlaying || GameTime.time - startTime >= duration) { Destroy(this.gameObject); } } }