Ability Script Mod for Audio Issues

Currently, if you add a Start Sound or Stop Sound to any abilities, the ability will stop all sounds on a gameObject when that ability is triggered.
Generally speaking you don't want to stop sounds from playing unless they are sounds that you are looping or should be stopped so that the stop sound can be played.

This is the code that is the problem (AudioClipSet.cs)
C#:
public void Stop(GameObject gameObject)
{
    AudioManager.Stop(gameObject);
}

When an ability plays the stop audio it stops all audio on the game object because the AudioClipSet class is calling the generic Stop method. It probably should be calling the Stop method with a reservedIndex so that it only stops the sound that it started and not all. Currently there is no way to get the reservedIndex of an audio clip that is playing without editing a lot of classes. I hope that the developer fixes this in the future.

To solve this on the short term, I have edited the Ability.cs script to add the following:

After line 93 - Add a new variable for "Should Stop Starting Sound"
C#:
[Tooltip("If the start sound is looping then make sure to stop it if other sounds are active.")]
[HideInInspector] [SerializeField] protected bool m_ShouldStopStartingSound = false;

After line 179 - Add the getter and setter for the new variable.
C#:
public bool ShouldStopStartingSound { get { return m_ShouldStopStartingSound; } set { m_ShouldStopStartingSound = value;  } }

In the AbilityStopped Method replace the m_StartAudioClipSet.Stop... with the following...
C#:
if (m_ShouldStopStartingSound)
{
    m_StartAudioClipSet.Stop(m_GameObject);
}

Now open the AbilityInspectorDrawer.cs

Around line 60 add:
C#:
InspectorUtility.DrawField(target, "m_ShouldStopStartingSound");

This will add the new checkbox to all abilities.

Now for each ability you have, if they require continuous input or their start audio file needs to be stopped before the stop audio file should be played, check the checkbox for the Should Stop Sound flag. This will just play the start audio for abilities and not stop them unless you indicate it should.

It would be great if the developer could let me know if this will cause more problems than I am solving but I didn't see any way around this without totally rewriting the AudioManager and AudioClipSet classes. This solution currently works and now all audio plays without stopping all other audio on a gameObject unless I want it to.
 
Thanks for posting this - I have made a note at this to take a closer look for the next release :)
 
Top