Before the start of any dialogue I need a particular sound to be played, depending on which conversant starts the dialogue.
For now I wrote AudioWait (mySound) in the Sequence field of Start node for each dialogue. How to code it for all issues at once?
How to play a specific sound before every dialogue?
Re: How to play a specific sound before every dialogue?
Hi,
Here are some suggestions:
Suggestion 1:
1. Add an Audio Source component to each NPC. Assign the sound that you would like to play. Untick Play On Awake and Loop.
2. Add a Dialogue System Events component to the NPC. Set the OnConversationStart event to play the Audio Source.
Suggestion 2:
1. Name the sounds according to the NPC names (e.g., "Adam", "Bob", "Charlie") and put them in a Resources folder.
2. Add this script (which uses script messages) to the Dialogue Manager:
PlayConversantGreeting.cs
Here are some suggestions:
Suggestion 1:
1. Add an Audio Source component to each NPC. Assign the sound that you would like to play. Untick Play On Awake and Loop.
2. Add a Dialogue System Events component to the NPC. Set the OnConversationStart event to play the Audio Source.
Suggestion 2:
1. Name the sounds according to the NPC names (e.g., "Adam", "Bob", "Charlie") and put them in a Resources folder.
2. Add this script (which uses script messages) to the Dialogue Manager:
PlayConversantGreeting.cs
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class PlayConversantGreeting : MonoBehaviour {
void OnConversationLine(Subtitle subtitle) {
if (subtitle.dialogueEntry.id == 0) { // Add AudioWait(npcName) to START
subtitle.sequence += "; AudioWait(" + subtitle.listenerInfo.Name + ")";
}
}
}
Re: How to play a specific sound before every dialogue?
Hi,
Going "suggestion 1" route, the sound plays simultaneously with the start of dialogue, not before.
Didn't try the "suggestion 2" yet, is there a way to control volume and other parameters of an audio clip with AudioWait?
Going "suggestion 1" route, the sound plays simultaneously with the start of dialogue, not before.
Didn't try the "suggestion 2" yet, is there a way to control volume and other parameters of an audio clip with AudioWait?
Re: How to play a specific sound before every dialogue?
Hi,
If you want it to play before the start of the dialogue, suggestion 2 is the way to go. AudioWait() doesn't provide parameters for volume control, but you can set them on the NPC's Audio Source or write a custom sequencer command to do so. They're actually quite simple to write, and the Dialogue System comes with a starter template.
If you want it to play before the start of the dialogue, suggestion 2 is the way to go. AudioWait() doesn't provide parameters for volume control, but you can set them on the NPC's Audio Source or write a custom sequencer command to do so. They're actually quite simple to write, and the Dialogue System comes with a starter template.
Re: How to play a specific sound before every dialogue?
Thank you for the great asset and excellent support!
Re: How to play a specific sound before every dialogue?
Happy to help!