Play PC voice lines in response menu

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
JaniElojoki
Posts: 2
Joined: Wed Jun 03, 2020 2:46 am

Play PC voice lines in response menu

Post by JaniElojoki »

Hey, I'm looking for a way to play voice lines in the response menu before selecting a response. I've added a button under the Response Button Template that, when clicked, would play the voice line but I'm having trouble figuring out how to get it to play the correct one.

The idea is that the player could listen to the possible response options before making a decision (this is to help players who might have trouble reading).

So far I've tried constructing an entryID similar to entrytags:

Code: Select all

public void constructCommand() {
		var dialogueEntry = DialogueManager.CurrentConversationState.subtitle.dialogueEntry;
		int conversationID = dialogueEntry.conversationID;
		int entryID = dialogueEntry.id;

		string entrytag = "Player_" + conversationID + "_" + entryID;

		DialogueManager.PlaySequence("AudioWait(" + entrytag + ")");
	}
		
However the button for each different response refers to the same ID, which is the same as the previous dialogue entryID and not any of the following PC IDs.

Any help would be appreciated!
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Play PC voice lines in response menu

Post by Tony Li »

Hi,

Look at the "Hover Response Button Example" on the Dialogue System Extras page. When you hover the mouse over a response button, it performs an action. In the example, it shows a text tooltip and shows a GameObject, both of which are based on information in the hovered response node. You'll see in the code that they key is to use the response's destination destination entry, not the current conversation state's dialogue entry.

In your case, you could play a voice line when the mouse hovers. Or you could change the example code to play the voice line when the button is selected (i.e., navigated to).
JaniElojoki
Posts: 2
Joined: Wed Jun 03, 2020 2:46 am

Re: Play PC voice lines in response menu

Post by JaniElojoki »

Hey Tony, thanks so much for the reply.

I've done as you suggested and now the functionality is just as intended!

Here's the finished method:

Code: Select all

public void constructCommand() {
		var response = GetComponent<StandardUIResponseButton>().response;
		int conversationID = response.destinationEntry.conversationID;
		int entryID = response.destinationEntry.id;
		string entrytag = "Player_" + conversationID + "_" + entryID;
		DialogueManager.PlaySequence("AudioWait( " + entrytag + ")");
	}
This script is then attached to the Response Button Template, which has the button object as a child that calls the method via an OnClick() UnityEvent.

Thanks again!
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Play PC voice lines in response menu

Post by Tony Li »

Happy to help!
Post Reply