audio.PlayOneShot Lag !

Hello , Is there any fix to audio.PlayOneShot ?
When the sound play , it play too slow :frowning:
Any idea ?

using UnityEngine;
using System.Collections;

public class DestroyByScore : MonoBehaviour {
	public Score scoreScript;
	public AudioClip AmerFX;

	
	void Start()
	{
		//Find Scripts GameObject, and get Score Component.
		scoreScript = GameObject.Find ("Score").GetComponent<Score>();
	}
	
	void Update()
	{
		if(scoreScript != null && scoreScript.score >= 100)
			Destroy (gameObject);
			audio.PlayOneShot(AmerFX);
	}
}

Thanks in advance!:slight_smile:

1 Answer

1

If the audio is a compressed format like .mp3 or .ogg, that will always take longer to play. Make sure you are using .wav for any sound effects.

@Amer_ALhwifi I didn't realize that you were using a 3D audio source. So the problem had to do with the time it took the audio to travel to your player?

–

I am trying to load an .ogg vorbis file with playOneShot and it is taking about a second just to play a quick preloaded 2kb sound... Is this normal? Is there a way around this other than using .wav?

–