playMaker

Author Topic: Set volume of multiple objects [SOLVED]  (Read 2784 times)

Jeremy11K

  • Playmaker Newbie
  • *
  • Posts: 14
Set volume of multiple objects [SOLVED]
« on: January 08, 2013, 01:09:08 AM »
Hi all,

I have a parent Game Object with a large amount of children underneath with Audio Sources that I need to set the volume of at the same time.

Would anyone know how to create something akin to "Set Volume Recursively"?

It would help me immensely as I have many scenes with the same issue and it will take me a very long time to do it individually.

Thanks,
JK
« Last Edit: January 09, 2013, 08:04:13 PM by Jeremy11K »

Jeremy11K

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Set volume of multiple objects
« Reply #1 on: January 08, 2013, 10:57:06 PM »
The other option is to be able to set volume by tag/layer?

Any ideas?

Thanks!
JK

Jeremy11K

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Set volume of multiple objects
« Reply #2 on: January 09, 2013, 12:51:16 AM »
Figured it out with the help of this page:

http://answers.unity3d.com/questions/306684/how-to-change-volume-on-many-audio-objects-with-sp.html

Basically reversed the solution & attached this code ^ to the objects I didn't want to be effected by the global volume, which were far fewer than the objects I wanted to control!

SOLVED!

JK

(kind of felt like a crazy person talking to myself this entire thread :O )

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set volume of multiple objects
« Reply #3 on: January 09, 2013, 02:10:39 AM »
Hi,

 Don't worry, this is very good that you ask AND solve your questions. It makes you feel competent, and others will benefit form your experience, so all positive, and not so crazy :)

Setting the audio listener volume is not really like setting the volume for a particular hierarchy tho, and you found a nice workaround.

 to do that "properly", you can implement a Fsm on each gameObject, and create a custom global event per "context", then you fire that event globally ("SET VOLUME FOR XXX"), and all fsm that implement that event will be able to set their audio volume. That would be the easiest and most direct way to do that.

 If you don't want to have an fsm for each GameObject, you can use the action "GetNextChild", and iterate again and again deeper in the hierarchy. Have you tried that?


bye,

 Jean

Jeremy11K

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Set volume of multiple objects
« Reply #4 on: January 09, 2013, 08:03:52 PM »
Hi Jean,

Thanks for that. Your proper solution certainly sounds more elegant than mine - I'll certainly keep your solution handy if/when I'm making my next app :)

JK