x


reduce overlaping sounds of a multi spawnd prefab on iphone?

is there a way to reduce overlaping sounds from a multi spawned prefab that uses a audio source?

if i spawn more of those prefabs i have to much sounds of it running at once. and i want to reduce them to 2 instead of hearing them all. 8 times the same sound is sure to much for my iphone app and they are looping too. xD

more ▼

asked Aug 02 '10 at 03:13 PM

SOIL gravatar image

SOIL
89 24 25 33

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

One easy solution would be to have a simple central (e.g. Singleton) sound manager that controls playing those sounds. You'd notify that sound manager whenever a prefab is instantiated and then the sound manager could decide whether or not to play the spawning sound.

Obviously, you'd have to switch "Play on Awake" off (personally, I never use this because I prefer to have more control).

Then, in your sound manager, get a reference to the AudioSource of the object that was just instantiated, and use Play() to start playing the sound. You might keep references to the objects playing sounds and check if there's already too many playing already. One way of doing so is isPlaying (you might also check for null references in case those objects might already have been destroyed ... so be a little careful there).

That should give you a good start.

more ▼

answered Aug 02 '10 at 03:23 PM

jashan gravatar image

jashan
10.1k 25 40 116

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1998
x522
x21
x1

asked: Aug 02 '10 at 03:13 PM

Seen: 917 times

Last Updated: Aug 02 '10 at 03:13 PM