- Home /
AudioSource.PlayOneShot playing loud and garbled
I have an Object Pool with 5 enemies that are recycled as they are destroyed and a Sound Manager script that checks if the enemy is destroyed and not reset but when it plays the explosion clip its loud and garbled sounding I am not sure whats going on I think maybe all of the enemys are calling the explosion clip at the same time but I dont see how as the script is on my Sound Manager the only thing on the enemy scripts are the bools for isDestroyed and isReset any help would be appreciated thanks
Can you share the scripts/code that you suspect are causing this functionality ?
@dacarrera public class Sound$$anonymous$$anager : $$anonymous$$onoBehaviour { [SerializeField] private AudioClip shipExplosionClip;
private AudioSource audioSource;
public static bool isDestroyed;
public static bool isReset;
private void OnEnable()
{
audioSource = GetComponent<AudioSource>();
}
private void Update()
{
if(isDestroyed && !isReset)
{
audioSource.PlayOneShot(shipExplosionClip);
}
}
}
reference in the DroneHealth Script if(currentHealth <= 0) { Sound$$anonymous$$anager.isDestroyed = true; ShipDie(); }
reference in the DroneTakeDamage Script else if (other.CompareTag("Reset")) { Sound$$anonymous$$anager.isReset = true; SendFullDamage(); }
reference in the DroneParticleEffects Script private void ReactivateDrone() { explosionEffect.SetActive(false); mesh.enabled = true; meshCollider.enabled = true; gameObject.SetActive(false); Sound$$anonymous$$anager.isDestroyed = false; Sound$$anonymous$$anager.isReset = false; }
Answer by ShadowsFallStudios · Nov 16, 2019 at 05:45 PM
Don't worry guy's me with 2 months of coding experience figured it out on my own. This has to be the worst answers section ever just a bunch of idiots that have no clue or technical ability great community smh
Your answer
Follow this Question
Related Questions
AudioSource.clip.time won't work? 2 Answers
Playing many audioclips with PlayOneShot causes all sound to cut out. 0 Answers
Truncate audio runtime 0 Answers
audio.clip.GetData() returns no data. 0 Answers
Unity 5 low audio volume 1 Answer