- Home /
Playing a sound effect on Touch HELP
if (Input.touches.Length > 0){
audio.PlayOneShot(myClip);
}
When I press on the screen, I'd like to play a audioclip immediately. But there's a small delay from the script above :S
Here's my import settings:
I've had problems in the past with Unity see$$anonymous$$g to put a small delay before playing a sound effect; not totally sure I ever resolved it fully. Here are some things you can check, though:
1) There could be a delay from loading the sound into memory when it is needed. Do you hear a delay if you play the sound several times in a row?
2) Try changing the "DSP Buffer Size" in audio settings to "Best Latency". Additionally, you can set the buffer size directly at runtime using the AudioSettings.SetDSPBufferSize (see http://docs.unity3d.com/Documentation/ScriptReference/AudioSettings.SetDSPBufferSize.html). It doesn't look entirely straightforward, but the documentation says you can adjust the buffer size at runtime to achieve extremely low latency for sound output.