• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Felipe_Schluepmann · Mar 09, 2021 at 10:49 AM · audiocharacterscripting beginnerdialogue

How to make dialogue system with voice

Hello I'm a beginner in unity and I'm trying to make a dialogue system, taking base from the brackeys system, however, I wanted to be able to have an audio play at the same time the text is displayed and to play the next line when you change the text, I tried to do something basically creating a system of a string that changes the name every time you change the text(it's basically the same as the normal system) and then at the end implement the audioManager.play(String); visual studios gives no errors however when I go into the game no audio is played. I will send my dialogue scripts down below (if you know about the brackeys system I have 3 scripts so I don't really know which one may be causing the problem)

DialogueManager Script:

 public class DialogueManager : MonoBehaviour
 {
     public Door1Animation doorAnimation;
 
     public Text nameText;
     public Text dialogueText;
     public Text changeText;
 
     public AudioManager Sound;
 
     public Animator textBoxAnimation;
 
     public Queue<string> sentences;
 
     public Queue<string> voiceLines;
 
     void Start()
     {
         sentences = new Queue<string>();
         voiceLines = new Queue<string>();
     }
 
     public void StartDialogue (Dialogue dialogue)
     {
         textBoxAnimation.SetBool("Open", true);
         
         changeText.text = ("Aperte R para continuar");
 
         nameText.text = dialogue.name;
 
         sentences.Clear();
 
         voiceLines.Clear();
 
 
 
         foreach (string sentence in dialogue.sentences)
         {
             sentences.Enqueue(sentence);
         }
 
         DisplayNextSentence();
 
         foreach (string voiceLine in dialogue.voiceLines)
         {
             voiceLines.Enqueue(voiceLine);
         }
 
         PlayNextLine();
 
     }
 
     public void DisplayNextSentence()
     {
         if (sentences.Count == 1)
         {
             changeText.text = ("Aperte R para fechar");
         }
 
         if (sentences.Count == 0)
         {
             EndDialogue();
             return;
         }
 
         string sentence = sentences.Dequeue();
         dialogueText.text = sentence;
     }
 
     public void PlayNextLine()
     {
         string voiceLine = voiceLines.Dequeue();
         Sound.Play(voiceLine);
     }
 
     public void EndDialogue()
     {
         Debug.Log("End of conversation");
         doorAnimation.openDoor = true;
         textBoxAnimation.SetBool("Open", false);
     }
 }

Dialogue Script:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;

 [System.Serializable]
 public class Dialogue
 {
 public string name;

 public Sprite Face;

 [TextArea(3, 10)]
 public string[] sentences;

 public string[] voiceLines;

 }

DialogueTrigger Script;

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;

 public class DialogueTrigger : MonoBehaviour
 {
 public Dialogue dialogue;

 public Image faceChange;

 public void TriggerDialogue()
 {
     faceChange.sprite = dialogue.Face;

     Debug.Log("Talk");
     FindObjectOfType<DialogueManager>().StartDialogue(dialogue); 
 }

 }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Cinder · May 31 at 10:11 PM

If you're looking for a node editor that integrates C# scripting I suggest Speech#. It also has audio files built into it's localization system. https://assetstore.unity.com/packages/tools/level-design/speech-dialogue-system-198911

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by ChrisMercado · Jun 02 at 09:47 AM

In my experience, it saved me a ton of time just buying a Dialogue asset off the asset store. The more time I spend developing, the more I find that for a lot of things that aren't custom to your game (dialogue systems, save systems, audio systems), simply buying an asset is better than spending days implementing it, then even more maintaining it.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

196 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

character in Reverb Zone? 1 Answer

Audio clip change via script,changing audio clip in audio source via script 1 Answer

Playing audio loop only when moving character controller 1 Answer

Character Collision Trigger Text Message Help! 1 Answer

Handling character customization 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges