playMaker

Author Topic: One Shot Audio Preferences  (Read 3022 times)

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
One Shot Audio Preferences
« on: May 15, 2013, 12:39:34 AM »
I use the "Play Random Sound" action a lot.  In my current project, each "One Shot" sound that's generated has a logarithmic rolloff that's too far away from the Audio Listener to hear.

Is there a way to also change a one-shot audios properties? Even if it's just to make the rolloff linear, that would fix everything.  I couldn't find an action or other way to make these changes, but I could have missed something.

Thanks.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: One Shot Audio Preferences
« Reply #1 on: May 15, 2013, 05:40:31 AM »
Hi,

 You could save your audioclip in a fsmObject and then set properties? would that work?

also, what property would you like to change?

bye,

 Jean

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
Re: One Shot Audio Preferences
« Reply #2 on: May 15, 2013, 11:54:15 AM »
The only property I need to change is the Audio Rolloff.  Changing it to Linear instead of Logarithmic would make it easily heard. 

I'm not certain what you mean by an fsmObject.  Do you just mean a prefab with Audio Source and FSM that sets the properties ahead of time?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: One Shot Audio Preferences
« Reply #3 on: May 15, 2013, 01:46:05 PM »
Hi,

 Yes, double checked, it's all possible right now.

 the easiest way is to lock the fsm you want to change the rolloff ( tho why don't you simply change the rolloff during editing?!).

when you have your fsm locked, select the gameObject in question, and drag the audio source component onto the state, and you will be able to choose between "Set Property" and "Get property", choose "set property", and then you can choose the RollOffMode and set it to linear.

But again, why do you need to do that at runtime? when you can simply set it in the inspector?

bye,

 Jean

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
Re: One Shot Audio Preferences
« Reply #4 on: May 15, 2013, 01:55:17 PM »
I can't set the property during editing because I'm not using an audio source action.  I'm using a "Play Random Sound" action, which doesn't require an audio source but instead it creates an object named "one shot", which is an instantiated audio source object. 
Since that object doesn't exist during editing, there's no way I can modify it in the editor, and I also cannot use Get/Set Property on the one shot objects for the same reason.  I can't use Get/Set Property during runtime either, because there's no way to find/store them accurately.
Play Random Sound is really useful, but there was no other way I could see to change the type of Audio Rolloff used by the one shot objects.

The reason I posted the question was to see if I missed something, or if the Play Random Sound action might be given additional properties to either 1) store the one shot object it creates as a variable, so I could then grab it and Set Property for the audio rolloff, or 2) allow me to set the audio properties in the action beforehand.

Does that make sense?

Thanks for your help.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: One Shot Audio Preferences
« Reply #5 on: May 15, 2013, 02:07:17 PM »
Hi,

 I see... indeed it's a unity problem:

http://answers.unity3d.com/questions/316575/adjust-properties-of-audiosource-created-with-play.html

I would create a different random system, use the random event and use states to properly play sounds on existing gameObject. Or you can have a prefab that you call to play the random sound,

bye,

 Jean