playMaker

Author Topic: Request for 'spatial blend' in One Shot Audio  (Read 4537 times)

charming_fox

  • Junior Playmaker
  • **
  • Posts: 62
Request for 'spatial blend' in One Shot Audio
« on: October 19, 2015, 05:17:12 AM »
Hi,

If anyone is capable of modifying the Play Sound action to include a 'spatial blend' slider (as Unity 5.2 defaults to fully 3D) that would be massively appreciated!

Thanks!

terri

  • Sr. Member
  • ****
  • Posts: 386
    • terrivellmann.tumblr.com
Re: Request for 'spatial blend' in One Shot Audio
« Reply #1 on: October 19, 2015, 10:49:42 AM »
It doesn't seem so simple because PlayClipAtPoint creates a new AudioSource with its own Spatial Blend but there is no reference to it.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Request for 'spatial blend' in One Shot Audio
« Reply #2 on: October 19, 2015, 10:58:58 AM »
When you use One Shot Audio you use it with the assumption that the default Audio Source settings are acceptable. Like Terri points out, it creates a new Audio Source and doesn't provide a reference to it.

I talked to superpig about modifying it to support more arguments or return an audio source but after he looked into it there are some complications in doing either.

The problem is that before 5.0 it was based off of the Audio file's import settings, but in 5.0 its all driven by the Audio Source. Since there isn't any reference to the Audio Source it basically makes One Shot Audio useless for anything but mono sound 2d games.

The only way to fix it is to roll your own One Shot that does what you need, which is possible but in practicality you probably want to make Audio Sources beforehand on your prefabs and objects so you can configure them. This is a better workflow.
« Last Edit: October 19, 2015, 11:01:10 AM by Lane »
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

charming_fox

  • Junior Playmaker
  • **
  • Posts: 62
Re: Request for 'spatial blend' in One Shot Audio
« Reply #3 on: October 19, 2015, 11:16:21 AM »
Thanks for the input guys, it's a real pain, we've got 100+ references to one shot audio which used to play 2D and now spatially at the uGUI canvas which is completeley useless, my own method of fixing this is to go through the whole project and replace those with references to an audio source right?

Cheers

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Request for 'spatial blend' in One Shot Audio
« Reply #4 on: October 19, 2015, 11:23:27 AM »
Correct, but 100's of Audio Sources for your UI is not efficient, so you'll want to build a better solution to work around this new issue.

If you are using this for your UI then you might consider making one or mode Audio Sources and when you need to play a sound just target that Source, change the clip to the proper one, play the Audio Source. For sounds in the same category (like Hovers, Clicks, etc) you can use the same Audio Source, or just do it all on the same one if you don't care if it overrides the currently playing sound.

That is super efficient, but requires a bit more work on each state needing to do this. (several actions for each one)

To take it another step further to optimization you could make a Template to do this for you, then just use Run FSM and input the necessary variables for it to fire off which would make it significantly easier to maintain.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

charming_fox

  • Junior Playmaker
  • **
  • Posts: 62
Re: Request for 'spatial blend' in One Shot Audio
« Reply #5 on: October 19, 2015, 12:05:02 PM »
Thanks Lane, you truly are a hero!

dudebxl

  • Hero Member
  • *****
  • Posts: 602
Re: Request for 'spatial blend' in One Shot Audio
« Reply #6 on: November 06, 2015, 08:05:25 AM »