- Home /
3d sounds don't work anymore when level is restarted
This is strange. I have 3d sounds on my scene (66 in total). Everything works fine the the first time the level is played but then, if i push the button to restart the level, this time not every 3d sound works, only some of them work! why this happens?
You would have to give more details. Are you restarting or reloading the scene? Restarting means you simply reposition some objects at initial position, reloading means you use Application.LoadLevel(); so everything goes back to 0.
Is this an issue to do with having more than 32 Audio Sources in the scene?
Answer by Mz3D · Nov 13, 2012 at 10:12 AM
I solved the problem: the issue was that the audio sources were set on "Play on awake" and the objects were instantiated inside the awake function, so i moved the object creation in the start function and now everything works.
You beat me to it. I just found the information I was looking for to clarify my comment, and you are correct. Unity can only play 32 audioSources at one time, so if you loaded the scene and all were set to PlayOnAwake, yes the problem you had would occur. Well done on fixing it !
When you force a stereo audio clip to mono, it sums the channels. It doesn’t just pick the left or right one. Unity has a set limit of 32 audio sources that can be playing simultaneously. When the game exceeds this number, audio sources with lower priority will still play on in virtual channels. This way, when the sound comes back in it will start at the point in the audio clip it would be at as if it were never muted. If you are using Unity pro, you can use the profiler. It has an audio tab that will show you how close you are to the 32 source limit and will show you how much memory/cpu audio is using.
Source : http://www.gameaudio101.com/Unity-Audio-Tips.php
Happy Coding =]
Your answer
Follow this Question
Related Questions
Sound only plays once 1 Answer
Playing music while scenes change? 4 Answers
Audio not coming out of speakers 1 Answer
How can I make my enemy detect and Run towards sound? 1 Answer
3D level generator on a grid C# 1 Answer