I'm using object pooling for a sound manager. Sounds are created/dequeued and a coroutine is started. The coroutine waits until the sounds stops playing (passing the clip's length as an argument) and then enqueues the object. The problem is, when a second sound is called before the first sound has stopped playing, it seems like the code that is waiting for the second coroutine to finish is canceled and the second sound will not be enqueued. Why is this?
The coroutines in question:
#Object pooling and coroutines
1 messages · Page 1 of 1 (latest)
They're called by this method
which is in turn called by weapon scripts when a gun is fired
Offtop but why u not waiting clip.length
you are creating a new instance of the queue
the coroutine "may" be attempting to enque in the previous instance
probably not the case but looks like it
yeah, the first line of CreateSoundObject looks like a bug
lets assume that coroutines dont capture the vars
(in any case i dont understand why you are recreating the same queue all the time)
would make sense to have a dictionary by string for queues for unique sounds
and you dont enqueue at all in CreateSound
which is what happens on the second sound
Exactly, this was the problem, thank you
I was just sleepy and didn't notice