Page 1 of 2

Stopping sound [UNRESOLVABLE]

Posted: Mon Mar 09, 2015 8:32 pm
by Granamir
Hi,
i'm having some problem stopping a sound.
I made an object in map play sound, unfortunatelly this sound lasts 40 seconds and i need to stop it when i change map (because i can hear it even if i changed map vertically, no matter map distance from the one playing).
I'd like to stop it instead avoid problem making new map really far from the one playing sound.
So far i tryed to destroy item playing, let him play silence, going 20 levels down (in a new map).
Anyone has a clue for me?
Ty

Re: Stopping sound

Posted: Mon Mar 09, 2015 9:04 pm
by minmay
Play your sound in a SoundComponent and use SoundComponent:stop() when you need to stop it.

Re: Stopping sound

Posted: Mon Mar 09, 2015 10:34 pm
by Granamir
works perfectly.
TY

Re: Stopping sound

Posted: Wed Mar 11, 2015 9:14 am
by Granamir
After some tests it come out it doesn't works.
Don't know why, on first try it worked perfectly. Later i tryed the whole procedure, step by step, that would lead party to play that sound and nothing happens. The i tryed to play it form console and again nothing happens, but if i play with playSound it works.
I tryed everything exept the right one.
Anyone can help me?
Ty

Code: Select all

function sottofondo()
	sound_1.sound:enable()
	sound_2.sound:enable()
	sound_1.sound:play("soundA")
	sound_2.sound:play("soundB")
end
i used 2 sound object disabling their sound component so they don't start playing form begining.
I call that function with a timer. Tryed with a print to see if it goes inside that functon and everything is fine, except i don't hear anything.

Re: Stopping sound

Posted: Wed Mar 11, 2015 9:31 am
by minmay
Is the party on the same level as the SoundComponent? If not, then of course they won't hear the sound. If you want a sound to persistently follow the party, adding SoundComponents to the party object will probably work.

Re: Stopping sound

Posted: Wed Mar 11, 2015 2:42 pm
by Granamir
k i think i got it
seems if party is disabled sound played by sound object can't be heard
and for some reason when i started that level with party already disbled i wasn't able to hear sound anymore, even if i enabled party later on
...so is there a way to hear sounds even if party is disabled? or a way to stop playSound?

Re: Stopping sound

Posted: Wed Mar 11, 2015 7:05 pm
by minmay
Er...what on earth do you mean by "party is disabled"?

Re: Stopping sound

Posted: Wed Mar 11, 2015 10:50 pm
by Granamir
minmay wrote:Er...what on earth do you mean by "party is disabled"?
this:

Code: Select all

for i = 1, 4 do
	party.party:getChampion(i):setEnabled(false)
end

Re: Stopping sound

Posted: Thu Mar 12, 2015 2:37 am
by minmay
Oh. Yes, if all 4 party members are disabled, no 3d or ambient sounds will be heard. The solution is don't do that in a situation where you want 3d or ambient sounds to be heard.

Re: Stopping sound

Posted: Thu Mar 12, 2015 2:36 pm
by Granamir
unfortunatelly i can't because of story reasons so i guess i have to use playSound with some limitations
Ty anyway