- Home /
2D game - how to optimize performance for audio when you do not need 3D audio?
Currently, I use this code to play 2d sound (just play a 3d sound at the camera, just because I don't need a 3d sound in this case)
public AudioClip pGameOver = null;
//...
AudioSource.PlayClipAtPoint(pGameOver, Camera.main.transform.position);
I don't know if it's better (in performance favor) to use the static function AudioSource.PlayClipAtPoint()
instead of creating an AudioSource
to call its Play()
function. Obviously, in the first option, I can't play 2d sound (I think), but if I use the second option I can play 2d sound. But I think the first option is more safe because I can play multiple sounds.
So how to optimize optimize performance for audio when I don't need 3D audio effect? All I need is playing a wav file as it is.
My target platform is Android.
You know you can play multiple audios with one audio source and in 2D sound. Just use aSouce.PlayOneShot(clip)
Answer by WinterboltGames · Mar 03, 2018 at 01:30 PM
In the audio source, inspector move the Spatial Blend to the very left and you are good to go. and then use AudioSource.PlayOneShot(Clip);
Your answer
Follow this Question
Related Questions
play sound while at certain coordinates of map (javascript) 1 Answer
Tracker modules on Android 0 Answers
Android Sound Crackling. 1 Answer
Why does sound on Android play at double speed and crackle? 3 Answers
Generate Chart with Data 0 Answers