Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: WillowN on October 31, 2017, 06:40:47 PM

Title: Audio play issue[SOLVED]
Post by: WillowN on October 31, 2017, 06:40:47 PM
I have an FSM set up on an object to send points to a GUI, play a sound and then destroy self. It worked fine except the sound was waaayyy too low using 'Play Sound'. After looking on the forum about this problem people recommended to use 'Audio Play' which is much better. The problem with that is that using Audio Play in that FSM stops 'Destroy Self' from working. It plays the sound and then the object stays lingering there. I separated out my FSMs. I placed one on a box collider trigger to Get Parent and then Destroy Object and then placed the play audio within the FSM that sends points. It all works now but the sound on 'Audio Play' is cut off way too much. If I set a delay on 'Destroy Object' then it looks really bad. How can I fix this? My objects are musical notes so the sound is really important.
Title: Re: Audio play issue
Post by: djaydino on October 31, 2017, 09:54:09 PM
Hi,
You can put the audio on a different object.
check out this thread :
http://hutonggames.com/playmakerforum/index.php?topic=16014.0
Title: Re: Audio play issue
Post by: WillowN on November 01, 2017, 12:38:58 PM
Thanks! I will dig into it now, much appreciated.
Title: Re: Audio play issue
Post by: WillowN on November 01, 2017, 02:00:04 PM
Ok. I think I got it. I have 3 FSMs on one object:
1.Trigger event>send event to global event> audio manager FSM which takes the global event and plays the sound
2. An FSM just for rotating the coin
3.Trigger event>get trigger info>set event data, send event (to my points GUI) then a wait>destroy object

I've replicated it a few times now with other note sounds. Thanks for your help, it took me a while to figure out what the best way to send triggers etc. If you have any suggestion for a better method please let me know.
Title: Re: Audio play issue
Post by: WillowN on November 01, 2017, 03:27:31 PM
One problem I ran into though is if I make the object into a prefab it forgets the target FSM (audio object).
Title: Re: Audio play issue
Post by: djaydino on November 01, 2017, 07:00:46 PM
Hi,
Yes this in normal it is the same with unity scripting, prefabs can not be connected to the scene objects

You could use broadcast event.

or make a global gameobject variable (called audio for example)
@ the start of the game use "set Game Object" and set your audio object into the global.
then refer to that variable.

But if you gonna have many coins created and destroyed @runtime you should look into pooling.
create/destroy is expensive and leaves garbage.