If you want to play different audio clips for each actor, see
How To: Vary Character Mumble Speak With Typewriter Effect.
---
To play a single audio clip when the typewriter starts, add a script with an OnConversationLine() method to the actor. Something like:
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class PlayAudioOnConversationLine : MonoBehaviour
{
public AudioClip audioClip;
void OnConversationLine(Subtitle subtitle)
{
if (subtitle.speakerInfo.transform == this.transform) AudioSource.PlayClipAtPoint(audioClip, transform.position);
}
}
---
If you want to play voice acted audio, on the other hand, see the
Cutscene Sequence Tutorials.
Hi again - much thanks to your advice, things have generally been going well, though I took a brief hiatus on development.
Right now, I want to ask about the audio implementation of the system again, particularly about the audio system I was implementing.
To be a bit more specific, I want to refocus on how to get the audio effects playing before a subtitle starts playing, to give it the impression of talking without going into mumblespeak.
Currently, I've been studying the script (and the documentation) that you had provided me before, but I'm unsure how to tell the Actor the current subtitle for the OnConversationLine function. I'm also unsure of what the AudioSource in that script is meant to be - I can't use the actor's own audiosource as it tells me that it's a 'Cannot be accessed with an instance reference' kind of member. I'm not sure what that means.
The way I want to go about things - I've divided a large array of different sound effects into tones (good, neutral, bad) and length (short, medium and long). I'm not sure how wise this is as an audio approach, but it's currently my in-between way of handling the character 'speech'.
But to keep it concise:
I'm unsure how to make it so each subtitle/conversation node has its own 'tone variable' - presumably I should employ the Lua stuff in it somehow?
I just want to be able to tell the script whether to use sound effects from a list of 'short and angrysounding' effects, or 'long and happy' for example.
Length could probably be figured out through accessing the subtitle's character count and adjusting appropriately, but I do want to know how to make it so the system/actor can tell whether the subtitle warrants a happy, annoyed or neutral tone of 'voice'.
Is this going to be particularly tedious? I imagine MOST of the conversations in-game are going to be neutral in tone, but I want the extra level of control, being able to make the voices sound happier or angrier for specific topics. I guess I could make the game default to the neutral tones when unspecified though.
I want to also trigger animator triggers for something like this as well with similar conditions, so that the character sprites have the correct expressions for the phrases.
Since a lot of these touch on the subtitle changes and I want to play specific audio & trigger animator/sprite changes on these dialog switches, I want to know how I can give a subtitle triggers to tell the other systems to make the appropriate changes, or have those systems read what the subtitle wants to do when it comes to setting animation triggers or playing specific audio clips.
Thanks in advance!