Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

Audio Issue, Plays with PlayOneShot but not Play

$
0
0
So my last question, I kind of fixed but the fix is only working for my Player not the enemies. I need a solution that works across the board. For some reason, the enemy audio isn't playing when using audio.Play(); but plays audio.PlayOneShot(); it's just that it sounds like it's either playing the audio twice at the same time or that audio gets stuck some. Below is the section of the code I'm using that has to do with the steps leading to the audio playing. AudioSource audio; public AudioClip eSound; private void Update() { if (eLife <= 0) { eDeath(); } if (isSinking) { transform.Translate(-Vector3.up * sinkSpeed * Time.deltaTime); } } void eDeath() { enemyAnim.SetBool("IsWalking", false); enemyAnim.SetBool("IsDead", true); //capsule.isTrigger = true; audio.clip = eSound; audio.PlayOneShot(eSound, 1); StartSinking(); } public void StartSinking() { agent.enabled = false; isSinking = true; Destroy(gameObject, 5f); } The enemy is instantiated using a spawning point because I thought that the destruction of the asset was the issue since I originally just had the prefab in the scene standing there. Please, help.

Viewing all articles
Browse latest Browse all 1488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>