Jump to content
Simas

How do you stop an in-progress sound?

Recommended Posts

I am interested in playing a 3D world-positioned sound effect and then stopping it at a certain point (using scripting).

Here is what I tried so far:

say3D and playSound3D when used on the same object do not replace/stop old sound but simply play the same sound again (on top of the old). Thus - not really possible to stop sounds started with these two functions.

The createSoundSource and then deleteVehicle on the sound object does not work (reported as a bug #8231).

Any other options I am missing?

Share this post


Link to post
Share on other sites
Set volume to 0?

can try fadeSound fadeMusic fadeRadio

Yeah.. but fade* functions affect all the sounds in game, right? Still an issue where I want to silence only the sound I have created/started.

Share this post


Link to post
Share on other sites

In AEG I have game logics use the say command to play the sound and then deleteVehicle the logic when I need it to stop. It stops immediately. I then re-create the logic if I need to start the sounds again.

  • Like 1

Share this post


Link to post
Share on other sites
In AEG I have game logics use the say command to play the sound and then deleteVehicle the logic when I need it to stop. It stops immediately. I then re-create the logic if I need to start the sounds again.

deleteVehicle doesnt delete the soundsource. did you say you use say?

Share this post


Link to post
Share on other sites
play a 'silent sound' instead

You mean "\a3\sounds_f\dummysound.wss"? But where do a play this dummy sound to stop any existing sounds? As mentioned, say3D and playSound3D will simply start a new dummy sound, completely ignoring and not stopping my old sound.

In AEG I have game logics use the say command to play the sound and then deleteVehicle the logic when I need it to stop. It stops immediately. I then re-create the logic if I need to start the sounds again.

Interesting.. Can you be more specific?

  • Like 1

Share this post


Link to post
Share on other sites
deleteVehicle doesnt delete the soundsource. did you say you use say?

I do not use a sound source, I have a game logic use "say" or "say3d" since it is invisible and deleteVehicle works without a problem.

---------- Post added at 11:08 ---------- Previous post was at 10:44 ----------

Interesting.. Can you be more specific?

Here is a simple version:

// Create side and group for logics if no already existing side or group.
_side = createCenter sideLogic;
_group = createGroup sideLogic;

// Create a global variable (public if necessary) to determine when to play a sound.
myBoolean = true;

// Create a game logic at the desired position and give it a name.
"Logic" createUnit [[0,0,0, _group, "mySoundLogic = this;"];

// Play the sound (make sure it is defined somewhere like Description.ext, a config file, etc.).
while {myBoolean} do
{
   mySoundLogic say ["mySound",5]; // "Say" the sound.
   sleep 5; // Adjust delay to match length of your sound.
};

// When you want to stop the sound, make the variable false and delete the logic (it does not have to be the same script) to make it stop immediately..

myBoolean = false
deleteVehicle mySoundLogic;

Share this post


Link to post
Share on other sites

A workaround i found is attaching an invisible object to player and using say3d to project sound from object

 

then when task is completed or i want sound to end i just deletevehicle the object

 

Not perfect but simple which is what I always try to go for

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×