AudioClip stuttering while loop is OFF and not using function Update?

Hi.

I have a problem. I’m making a game where there are pixel art ‘BOMBS’ as enemies.
My player dies when he hit the bomb, and exploding animation plays, and an AudioClip should play once.
However, the AudioClips starts repeating itself an infinite amount of times, resulting in a sound that sounds like my computer is stuck.

Here is the code attached to the bomb.

using UnityEngine;
using System.Collections;

public class bombScript : MonoBehaviour {

	Animator animator;
	SpriteRenderer bomb;
	static public bool hitbomb = false;
	GameObject dragon;
	AudioSource bombAudio;
	public AudioClip bombClip;

	// Use this for initialization
	void Start () {
		animator = gameObject.GetComponentInChildren<Animator> ();
		dragon = GameObject.FindGameObjectWithTag ("Player");
		bombAudio = GameObject.Find ("SoundManager/bombAudio").GetComponent<AudioSource> ();
	}

	void OnTriggerEnter2D(Collider2D player) {

		if(dragon.GetComponent<beta_DragonMovement>().Godmode == true)
			return;

		if (player.tag == "Player") {
			bombAudio.PlayOneShot (bombClip);
			bomb = gameObject.GetComponent<SpriteRenderer> ();
			bomb.enabled = false;
			hitbomb = true;
			animator.SetTrigger ("death");
		}
	
	}
		
}

I also tried the following script:
It resulted in the same problem.
Wah wah.

using UnityEngine;
using System.Collections;

public class bombScript : MonoBehaviour {

	Animator animator;
	SpriteRenderer bomb;
	static public bool hitbomb = false;
	GameObject dragon;
	AudioSource bombAudio;

	// Use this for initialization
	void Start () {
		animator = gameObject.GetComponentInChildren<Animator> ();
		dragon = GameObject.FindGameObjectWithTag ("Player");
		bombAudio = GameObject.Find ("SoundManager/bombAudio").GetComponent<AudioSource> ();
	}

	void OnTriggerEnter2D(Collider2D player) {

		if(dragon.GetComponent<beta_DragonMovement>().Godmode == true)
			return;

		if (player.tag == "Player") {
			bombAudio.Play ();
// the bombClip is pre-set in the inspector.
			bomb = gameObject.GetComponent<SpriteRenderer> ();
			bomb.enabled = false;
			hitbomb = true;
			animator.SetTrigger ("death");
		}
	
	}
		
}

This calls for some debugging. I would guess that your player hits multiple bombs that all start playing your clip. Add a Debug.log(“some log string”); and check how often it is called.

You could use your static hitbomb boolean to only play the audio when hitbomb is false so that it only plays for one bomb.

Happy debugging!