playMaker

Author Topic: Calling an Audio Source  (Read 815 times)

o4401

  • Playmaker Newbie
  • *
  • Posts: 10
Calling an Audio Source
« on: July 08, 2020, 07:09:43 AM »
Hi All,

I have clicking sound that I would like to use for every button clicks in my game.
If I add it to every single button's FSM with a Play Sound action, then if I would later want to change this sound for every button, then I would have to change the sound one-by-one in every button's FSM.

How would it be possible to somehow use a single sound in all FSM's, where the sound file played could be replaced at 1 single place and all of the FSM's would use that new file from then on?

Do you have any ideas or solutions how this could be done?

Thanks!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Calling an Audio Source
« Reply #1 on: July 08, 2020, 12:28:48 PM »
Hi.
Make a fsm on a separate object (call it Audio Handler for example)

Then Place states with an 'Audio Play' action and set a Global Transition to those states.
Don't use 'Play Sound' if you repeating a audio as you will create a object with a Audio Source each time you do.

Then from the 'button' fsms use a 'Send Event' or 'Send Event By Name' and target the Audio Handler.

Here is a video about transitions :