Where is audiosource and how can I change it?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
talesworth
Posts: 8
Joined: Thu Aug 01, 2024 1:52 pm

Where is audiosource and how can I change it?

Post by talesworth »

I can't seem to find the audiosource being used by DSU. I need to adjust it (mainly volume) based on the sound settings in the game's options menu. Also, I want to stop the audio sometimes, for example when the player wants to skip through a cutscene. Pulling my hair out on this one, please help :cry:
User avatar
Tony Li
Posts: 23252
Joined: Thu Jul 18, 2013 1:27 pm

Re: Where is audiosource and how can I change it?

Post by Tony Li »

Hi,

If you're using sequencer commands such as Audio(), AudioWait(), SALSA(), etc., they use the Audio Source component that's on the subject. (In general, if you don't specify the subject then it's the GameObject associated with the dialogue entry's speaker.) If an Audio Source doesn't already exist on that GameObject, the sequencer command will create a default one. You can also add a Dialogue Actor component to a GameObject if you want to specify an alternate Audio Source location.

I recommend setting up an Audio Mixer asset with audio mixer groups for music, sfx, voice, etc. Then assign the appropriate mixer group to the Audio Source. This way you can change the audio mixer group's volume and it will automatically affect all Audio Sources assigned to that mixer group.
talesworth
Posts: 8
Joined: Thu Aug 01, 2024 1:52 pm

Re: Where is audiosource and how can I change it?

Post by talesworth »

I do have a sound manager that handles setting sound, but I don't have DialogueActor's setup. I just want the narrator, and any NPCs, to speak through the same audio source. However, it looks like the AudioSource doesn't exist until dialogue starts since it is created one the fly and put on DialogueManager. Since it's not always there, I can't pre-set it to the right volume. How can I just have all my dialogue come through an AudioSource that I'm in control of?
User avatar
Tony Li
Posts: 23252
Joined: Thu Jul 18, 2013 1:27 pm

Re: Where is audiosource and how can I change it?

Post by Tony Li »

Hi,

If you're talking about audio played by sequencer commands such as Audio() and AudioWait(), then two options are:

1. Specify the single Audio Source GameObject by name in the command. Concept example:

Code: Select all

AudioWait(myaudioclip, MyAudioGameObjectName)
2. OR make a subclass of the sequencer command (e.g., SequencerCommandAudioWait.cs) and override the GetAudioSource() method. Concept example:

Code: Select all

public class SequencerCommandCustomAudio : SequencerCommandAudioWait
{
    protected override AudioSource GetAudioSource(Transform subject) => return MyAudioGameObject;
}
Then use CustomAudio() in place of AudioWait().
Post Reply