Manage audio source problems (Adventure Creator related question)

Bukyja

New member
hi guys got a question, i have a problem to control footstep sound volume, i'm controlling it via Adventure Creator script, and usually it works pretty well, which bypass SFX volume on options menu, i've noticed that while player is normally in scene editor it have only 1 audio source per feet, but when i hit play magically appear 2 audio source per feet, which of those 2 i can control only 1, it is a bug? Why player need 2 audio source to play SFX sound? Any help? Pleeease


Here 2 screeshots
 

Attachments

  • Screenshot (59).png
    Screenshot (59).png
    514.9 KB · Views: 7
  • Screenshot (61).png
    Screenshot (61).png
    546.1 KB · Views: 7
Multiple AudioSources is not a problem. A new AudioSource will be added if a new AudioClip is requested to play when another clip is already playing.
 
Multiple AudioSources is not a problem. A new AudioSource will be added if a new AudioClip is requested to play when another clip is already playing.
I see, any suggestion on how to manage multiple audio source? A audio mixer can be a good alternative? I've set up perfectly My player, i'm Just missing to manage footstep soung via options menu. Thank you
 
I haven't used AudioMixers though I need to look into those - they do seem like they may help for that situation.
 
This works for audio being passed directly to the output but if you want the sounds to have an affect in the 3D space you will still need to control the volume of each audio source.

For controlling the snapshots you could do something like this:

Code:
public class FootStepState : StateBehavior
{

    public AudioMixerSnapshot standing;
    public AudioMixerSnapshot crouching;
    [SerializeField] protected bool isCrouching = false;
    public bool crouchVolume { get { return isCrouching; } set { isCrouching = value; } }


    public override void StateChange()
    {
        base.StateChange();
        if (isCrouching) crouching.TransitionTo(0f);
        else standing.TransitionTo(0f);
  
  
    }
}

Then make a preset that listens for the crouching state

If you want to have your changing sound affect the reactions of AI you could do something like this (add it to the player's pelvis), though it's probably not the neatest way to do it.
maybe someone with more programming skills could suggest a better way.

Code:
public class DynamicFootStepState : StateBehavior
{
    public AudioSource[] foot;
    public float standingVolume = 0.4f;
    public float croucthingVolume = 0.05f;
    [SerializeField] protected bool isCrouching = false;
    public bool crouchVolume { get { return isCrouching; } set { isCrouching = value; } }

    public override void StateChange()
    {
        base.StateChange();
        if (isCrouching)
        {
            foot = gameObject.GetComponentsInChildren<AudioSource>();
            foreach (var item in foot)
            {
                item.volume = croucthingVolume;
            }
        }
        else
        {
            foot = gameObject.GetComponentsInChildren<AudioSource>();
            foreach (var item in foot)
            {
                item.volume = standingVolume;
            }
        }
    
    
    }
}
 
Last edited:
This works for audio being passed directly to the output but if you want the sounds to have an affect in the 3D space you will still need to control the volume of each audio source.

For controlling the snapshots you could do something like this:

Code:
public class FootStepState : StateBehavior
{

    public AudioMixerSnapshot standing;
    public AudioMixerSnapshot crouching;
    [SerializeField] protected bool isCrouching = false;
    public bool crouchVolume { get { return isCrouching; } set { isCrouching = value; } }


    public override void StateChange()
    {
        base.StateChange();
        if (isCrouching) crouching.TransitionTo(0f);
        else standing.TransitionTo(0f);
 
 
    }
}

Then make a preset that listens for the crouching state

If you want to have your changing sound affect the reactions of AI you could do something like this (add it to the player's pelvis), though it's probably not the neatest way to do it.
maybe someone with more programming skills could suggest a better way.

Code:
public class DynamicFootStepState : StateBehavior
{
    public AudioSource[] foot;
    public float standingVolume = 0.4f;
    public float croucthingVolume = 0.05f;
    [SerializeField] protected bool isCrouching = false;
    public bool crouchVolume { get { return isCrouching; } set { isCrouching = value; } }

    public override void StateChange()
    {
        base.StateChange();
        if (isCrouching)
        {
            foot = gameObject.GetComponentsInChildren<AudioSource>();
            foreach (var item in foot)
            {
                item.volume = croucthingVolume;
            }
        }
        else
        {
            foot = gameObject.GetComponentsInChildren<AudioSource>();
            foreach (var item in foot)
            {
                item.volume = standingVolume;
            }
        }
   
   
    }
}


Thank you, i'll try it asap :D
 
@Bukyja

Can you do me a favour? I'm experiencing some strange behavious with footstep sounds after running for about 30 seconds. All the sounds start to get clipped and don't play the whole sound file.

WIf you've set up your surface manager in your own terrain would you mind testing to see if you get this behaviour as well?

I don't get this behavioud in the demo scene so it's something unique to my set up but I'd just like to rule out that it's not something beyond my setup.

Thanks
 
@Bukyja

Can you do me a favour? I'm experiencing some strange behavious with footstep sounds after running for about 30 seconds. All the sounds start to get clipped and don't play the whole sound file.

WIf you've set up your surface manager in your own terrain would you mind testing to see if you get this behaviour as well?

I don't get this behavioud in the demo scene so it's something unique to my set up but I'd just like to rule out that it's not something beyond my setup.

Thanks

Hi, at least i've removed UFPS due to this sound problem, i didn't had time to try more stuff and i think i'll create a new first person controller to be more compatible to Adventure creator, this thing of multiple audio source not controllable isn't good for my project, plus i've noticed one more audio source pop-up from manager which is uncontrollable too. Thanks for the help anyway :D
 
Top