playMaker

Author Topic: Play audio advance  (Read 8165 times)

dudebxl

  • Hero Member
  • *****
  • Posts: 602
Play audio advance
« on: November 05, 2015, 06:37:21 PM »
For unity 5.2+

  • Fire one shot audio with Audio Source setup (Spatial blend, Volume, Mixer, etc)
    [No need to attach Audio Source to object - auto-create with the one shot option_on and action setup.]
or
  • Setup or edit Audio Source on a GameObject

Note: No Mixer/audio FX options (see http://hutonggames.com/playmakerforum/index.php?topic=11218.0). Optional to add Audio Source to object as action will create it if none exist. Snapshot basic Transition (http://hutonggames.com/playmakerforum/index.php?topic=11603.0) or Transition Between 2 Snapshots (http://hutonggames.com/playmakerforum/index.php?topic=11039.0).

on ecosystem or https://snipt.net/dudebxl/playaudioadvance/
« Last Edit: November 07, 2015, 11:55:56 AM by dudebxl »

Tubbritt

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Play audio advance
« Reply #1 on: November 06, 2015, 01:12:16 PM »
Hello.
Thank you kindly for taking the time to write this.

I'm just testing this here right now and I'm not sure the volume slider is working. Can you please take a look at that?

I sincerely appreciate your efforts. This is looking quite good.

Kind regards
James.

dudebxl

  • Hero Member
  • *****
  • Posts: 602
Re: Play audio advance
« Reply #2 on: November 06, 2015, 01:22:09 PM »
hahaha, thx, i forgot to add the volume. Silly me...

Done. please download v1.0.1 from ecosystem or snipt.

 :o

Tubbritt

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Play audio advance
« Reply #3 on: November 06, 2015, 03:17:17 PM »
Perfect...!!! Wow... thanks a million.
This works extremely well indeed.

Much appreciated

James.

foxdeltagames

  • Junior Playmaker
  • **
  • Posts: 62
Re: Play audio advance
« Reply #4 on: November 12, 2015, 09:12:57 AM »
 Are One Shot sou ds actual game objects that get created with nust that one sound that gets played?

If so let me ask you this. is there a way to add an option to the action that lets you set the tag of that one shot sound game object? If so, it can be useful for game that the AI needs to detect sound. i.e. the one shot sound is created, the AI finds the object by its tag, get the distance, if the distance is close enough it then "hears" the sound. See what i getting at?i think it will be a neat feature if possible to add.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7614
    • jinxtergames
Re: Play audio advance
« Reply #5 on: November 12, 2015, 03:17:21 PM »
Hi,
Actually you can do this...
Once your One shot audio is active you need to use "Find Game Object"
and set object name to "One shot audio" and store the gameobject
the use "Set Tag"

BUT if more than one "One shot audio" is active it does not work.

btw. the one shot game object will spawn on the same position as the game object the action on or targeted to,
so if you get the distance from that game object it will be the same result.

dudebxl

  • Hero Member
  • *****
  • Posts: 602
Re: Play audio advance
« Reply #6 on: November 13, 2015, 07:44:11 AM »
+1 for djaydino  ;D

szomaza

  • Sr. Member
  • ****
  • Posts: 253
Re: Play audio advance
« Reply #7 on: December 26, 2018, 10:56:54 AM »
Thank you dudebxl!

This looks very handy but might be overkill for my current requirement.

I was looking for the differences:
- of just playing a one shot sound or,
- playing the same sound with SetAudioClip or in the AudioSource inspector on a game object.
How these 2 methods compare to each other and which one is better for mobile performance?

Unfortunately I did not find such a comparison or hints and tips how to do audio for mobile.

What I am doing is I'll have a bunch of dynamic objects which take damage and finally break. When they break they have to play a break sound.
Now in editor this works perfectly with the PlaySound action, but I am not sure if many sounds played like this will be optimal for mobile.

Would it be better to:
- have an AudioSource on each object and use the play audio actions,
- or have some audio manager game object with the one AudioSource and have that play every sound?

Anybody please share some experience with how to do audio for mobile, properly.

Thanks in advance!
Br,
szomaza

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7614
    • jinxtergames
Re: Play audio advance
« Reply #8 on: December 31, 2018, 01:49:26 AM »
Hi.
I usually have a fsm called SoundManager or Audio manager with 1 AudioSource component.
when i need more/other sound i make some child objects with an audio AudioSource component

Then i set global events for each different sound.

and then i use send event to trigger the sounds i need :)

szomaza

  • Sr. Member
  • ****
  • Posts: 253
Re: Play audio advance
« Reply #9 on: December 31, 2018, 09:31:24 AM »
Thanks for the advice, that sounds like the proper setup.

But with that I am missing one thing: playing sounds that way (with an audio manager and global events) you can't set the position of the audio, right?

I can't find where to set position in this case, as only the Play Sound action has Position, so I guess in this case it plays from the object which has the AudioSource component.

Please confirm that if you want to position your sounds then you use this method:
 "when i need more/other sound i make some child objects with an audio AudioSource component"

This way every object which needs to give off a positional audio would have an AudioSource component.

Which should still be less processing intensive as simply using the Play Sound action every time, which creates the "One Shot Audio" objects with AudioSource component, right?

By using the Play Sound action, these "One Shot Audio" objects with AudioSource component are created and destroyed all the time, which is I guess quite bad for performance.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7614
    • jinxtergames
Re: Play audio advance
« Reply #10 on: January 01, 2019, 11:55:16 PM »
Hi.
If you need the audio on position it is better to have the component on the object.

Then if the object uses multiple sounds you can use a 'sound manager' on that object.