• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Destroying a sound really destroys it!

Status
Not open for further replies.
Level 14
Joined
Aug 30, 2004
Messages
909
I'm using some custom sounds that I've imported into my map.

When I "Destroy Sound" after I play it to clear up the memory leak the sound stops playing immediately (so I don't hear it) and apparently really destroys it, as when I try to play it later in the same game, even without the "destroy" command, it still doesn't play.

As part of my play testing, I tried destroying the sound before I played it, then played it 5 seconds later in the same trigger. The sound didn't play. When I took the "Destroy Sound" action out of the trigger and tried the game again, the sound did play.

I want to use the same sound many times, but I don't want to leak every time I play the sound. How on earth do I avoid that?

Darwin
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,286
You store the sound in a global reserved for only that sound. Every time you want to play it, you reference that variable. If you have problems playing the same sound multiple times simply make an array system where there are multiple different objects of the same sound. You should never have to destroy sounds and the only possible time you should need to is if the sound will not ever be used again in the map.
 
Level 14
Joined
Aug 30, 2004
Messages
909
You store the sound in a global reserved for only that sound. Every time you want to play it, you reference that variable. If you have problems playing the same sound multiple times simply make an array system where there are multiple different objects of the same sound. You should never have to destroy sounds and the only possible time you should need to is if the sound will not ever be used again in the map.

Excellent, thank you. I got confused when I was reading about leaks. They say sound variables leak so you should destroy them immediately afterwards. But I suppose I don't have to do that unless I don't need the sound anymore.

Thanks again. + rep
 
Status
Not open for further replies.
Top