Forum rules - please read before posting.

Sound component for footstep sound managing in UFPS

Hello, i'm getting a problem with AC sound component and footsteps sound in UFPS, what i've seen is that when i'm in scene editor the player have 1x audio source per feet so adding sound component i must manage those audio source without problems via options menu, anyway when i hit play magically UFPS pop up a second audio source per feet which is uncontrollable even with Sound component, anyone got any problem like this? Any way to modify Sound script to let it manage multiple audio source per object? Or another kind of solution would be very appreciate. Many thanks

Here 2 screenshot

https://imgur.com/a/PkUaCeZ

Comments

  • If UFPS is adding an AudioSource component to a GameObject that already has one, then that's a bug with UFPS.

    You're using the AC Sound component simply to sync its volume to the AC SFX volume option? A Sound component isn't strictly necessary to do that, you can replace it a custom script attached that listens to the OnChangeVolume / OnSwitchProfile custom events:

    using UnityEngine;
    using AC;
    
    public class SyncAudio : MonoBehaviour
    {
    
        private void OnEnable ()
        {
            EventManager.OnChangeVolume += OnChangeVolume;
            EventManager.OnSwitchProfile += OnSwitchProfile;
        }
    
        private void OnDisable ()
        {
            EventManager.OnChangeVolume -= OnChangeVolume;
            EventManager.OnSwitchProfile -= OnSwitchProfile;
        }
    
        private void OnChangeVolume (SoundType soundType, float volume)
        {
            if (soundType == SoundType.SFX)
            {
                GetComponent <AudioSource>().volume = volume;
            }
        }
    
        private void OnSwitchProfile (int profileID)
        {
            GetComponent <AudioSource>().volume = Options.GetSFXVolume ();
        }
    
    }
    
  • I've already asked to Opsive forum too, they told me its not a bug just a feature, because is necessary to add an audio source to play something else while another is already playing SFX, the real problem is, if i change volume during gameplay sound volume isn't equal, but if i change volume during gameplay, than quit and re-play sound volume is equal at the last set up i did :( Do you think this example script you gave me would help me? What about audio mixers, theres an Adventure Creator tutorial covering how to use it?

  • Details on how to use Audio Mixers with AC's sound system can be found in the Manual's "Sound" chapter - but they too require use of the Sound component.

    The script I wrote above is a replacement for the Sound component - give it a try and see if it works for you.

  • Thanks Chris, i did a few try but seems like it doesn't work, either if i put it in a model i have already sound component on it.

  • edited March 2020

    I'm not clear on what you're saying, there. Don't rely on a Sound component - this replaces it.

  • Yes i'm sorry, I meant that I used it on a mesh on which sound component worked without problems, I removed sound component and I used this script instead, but with this I can't adjust the volume.

  • edited March 2020

    How/when are you adjusting the volume? If it's not updating when the game begins, does it update if you change the volume slider in an Options menu at runtime?

    Is it possible that UFPS is also controlling the AudioSource's volume? Here's an alternative that will show Console messages when the volume is being changed by it:

    using UnityEngine;
    using AC;
    
    public class SyncAudio : MonoBehaviour
    {
    
        private void OnEnable ()
        {
            EventManager.OnChangeVolume += OnChangeVolume;
            EventManager.OnSwitchProfile += OnSwitchProfile;
        }
    
        private void OnDisable ()
        {
            EventManager.OnChangeVolume -= OnChangeVolume;
            EventManager.OnSwitchProfile -= OnSwitchProfile;
        }
    
        private void OnChangeVolume (SoundType soundType, float volume)
        {
            if (soundType == SoundType.SFX)
            {
                GetComponent <AudioSource>().volume = volume;
                Debug.Log ("Set volume to: " + volume);
            }
        }
    
        private void OnSwitchProfile (int profileID)
        {
            GetComponent <AudioSource>().volume = Options.GetSFXVolume ();
            Debug.Log ("Set volume to: " + Options.GetSFXVolume ());
        }
    
    }
    
  • Actually the problem is only while i change the volume slider in an Options menu at runtime, on 2 audio source per feet only 1 set correctly, playing random footstep sounds with volume set by me and some with volume at max.

    Thanks Chris, i'll try to investigate on opsive forum, due to sound component for me works for everything except UFPS, so must be something strange with it.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.