Im playing a sound for health pickups and from the moment they appear the pick up sound starts, the audio source doesn’t have “loop” option ticked so what else could it be?
Is it supposed to play before or after the player picks it up?
Do their AudieSource components have Play On Awake
checked?
So, your code is called every frame, So its going to loop and sound hideous. There are 2 ways of solving this.
public AudioSource audioSource;
private bool ticked;
private void Start()
{
audioSource = GetComponent<AudioSource>();
// Play it in here
audioSource.Play();
}
private void Update()
{
// OR, make a bool (as you can see "tick")
if (!ticked)
{
audioSource.Play();
ticked = true;
}
}
As you can see, those are the 2 ways i would prevent it from looping. first one i highly recommend if you want to play it on start, or even just tick play on awake, on the audio source and that should fix it. Other method is just using a bool to act as a toggle. Hope this helped you.