playMaker

Author Topic: Audio play issue[SOLVED]  (Read 110 times)

WillowN

  • Playmaker Newbie
  • *
  • Posts: 16
    • View Profile
Audio play issue[SOLVED]
« on: October 31, 2017, 03: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.
« Last Edit: November 01, 2017, 11:12:48 PM by jeanfabre »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 2291
    • View Profile
    • jinxtergames
Re: Audio play issue
« Reply #1 on: October 31, 2017, 06: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

WillowN

  • Playmaker Newbie
  • *
  • Posts: 16
    • View Profile
Re: Audio play issue
« Reply #2 on: November 01, 2017, 09:38:58 AM »
Thanks! I will dig into it now, much appreciated.

WillowN

  • Playmaker Newbie
  • *
  • Posts: 16
    • View Profile
Re: Audio play issue
« Reply #3 on: November 01, 2017, 11:00:04 AM »
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.

WillowN

  • Playmaker Newbie
  • *
  • Posts: 16
    • View Profile
Re: Audio play issue
« Reply #4 on: November 01, 2017, 12: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).

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 2291
    • View Profile
    • jinxtergames
Re: Audio play issue
« Reply #5 on: November 01, 2017, 04: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.