5 Minute DIALOGUE SYSTEM in UNITY Tutorial

  Рет қаралды 156,263

BMo

BMo

3 жыл бұрын

Dialog? Dialogue? Either way, in this Unity Tutorial we'll be looking at adding a simple system into our game that types out sentences one character at a time.
Dialogue systems can get pretty elaborate, and this solution is obviously not going to support anything extensive, but its a great starting point for just being able to get a narrative into your game and interactions with NPCs.
In the video I have the conversation being triggered by the Start method of our script, but you could use triggers or key inputs to call StartDialogue() from any way that you'd want.
✨Want to support the channel?
Buy me a coffee ☕: ko-fi.com/bmoli
➤LIKE the video if you enjoyed, it really helps the channel!
➤MORE 5 Minute Tutorials: • 5 Minute Games
➤Join our DISCORD SERVER: / discord
We have channels to help you with your problems!
#bmo #unity #tutorial

Пікірлер: 274
@igseatsyursoul
@igseatsyursoul 2 жыл бұрын
Finally a dialogue that is basic with no bells and whistles that I can fully customize. Too many of the other tutorials on this added way more than I want for my small game.
@LaneWatson
@LaneWatson 3 жыл бұрын
Ahh yes. Got my 5 minute fix. The most useful tutorials on Unity.
@BMoDev
@BMoDev 3 жыл бұрын
Haha thanks! Appreciate ya
@PlagueDoctor856
@PlagueDoctor856 5 ай бұрын
INCORRECT! THIS VIDEO IS 5:10 MINUTES LONG
@Cerified
@Cerified 4 ай бұрын
For those who are confused as to where to put your text. When you go to the DialogueBox’s inspector, underneath the Dialogue script tab, there’s another tab called ‘Lines’. That’s where you add it! :)
@user-sd6mp8jv2v
@user-sd6mp8jv2v 3 ай бұрын
nice
@amyguzman3502
@amyguzman3502 3 ай бұрын
Hm weird, I cannot find it
@amyguzman3502
@amyguzman3502 3 ай бұрын
nvm just found it!
@agustinquindimil6594
@agustinquindimil6594 2 ай бұрын
I can put this script anywhere and then call it when I press "e" lets say, right?
@dr.adammoore
@dr.adammoore Жыл бұрын
Most efficient Unity tutorial I've ever seen--and it makes perfect sense! You just made my day. And, my first subscribed channel ever. Thank you.
@djt3rrv875
@djt3rrv875 2 жыл бұрын
God thank you SO MUCH for including the complete on click function!!!! A lot of tutorials don't, and it really sucks as a player to be waiting and waiting for this shit to type itself out (especially if you read fast). Such a clean and clear cut tutorial!!! Thank you!!!
@BMoDev
@BMoDev 2 жыл бұрын
Appreciate it!
@revmatch6r
@revmatch6r 3 жыл бұрын
Exactly what I needed. These are the best I've been able to find. Looking forward to more videos soon 🙌
@BMoDev
@BMoDev 3 жыл бұрын
Thanks dude!
@bigp0y
@bigp0y 3 жыл бұрын
Missed you, Bmo! Keep up the good work - I find your vids some of the easier tutorials to follow
@BMoDev
@BMoDev 3 жыл бұрын
😘
@section8entertainment961
@section8entertainment961 Жыл бұрын
using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; public class Dialogue : MonoBehaviour { public TextMeshProUGUI textComponent; public string[] lines; public float textSpeed; private int index; // Start is called before the first frame update void Start() { textComponent.text = string.Empty; StartDialogue(); } // Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { if (textComponent.text == lines[index]) { NextLine(); } else { StopAllCoroutines(); textComponent.text = lines[index]; } } } void StartDialogue() { index = 0; StartCoroutine(TypeLine()); } IEnumerator TypeLine() { foreach (char c in lines[index].ToCharArray()) { textComponent.text += c; yield return new WaitForSeconds(textSpeed); } } void NextLine() { if (index < lines.Length - 1) { index++; textComponent.text = string.Empty; StartCoroutine(TypeLine()); } else { gameObject.SetActive(false); } } }
@yaboishadowninja
@yaboishadowninja Жыл бұрын
Thank you. I was following the video but for some reason it wasn't working. However, this did.
@Rdect25
@Rdect25 Жыл бұрын
chad
@fullgames8195
@fullgames8195 10 ай бұрын
You are PERFECT
@innawoodsfmj
@innawoodsfmj 7 ай бұрын
life saver you are
@TwoClutch
@TwoClutch 6 ай бұрын
i love you dad
@ertyuu35
@ertyuu35 2 жыл бұрын
Thank you so much. Even though I watched a 30 minute tutorial, I couldn't' do it, but thanks to your 5 minute tutorial, I did it easily.
@BMoDev
@BMoDev 2 жыл бұрын
love to hear it
@lordkakabel76
@lordkakabel76 3 жыл бұрын
I love the way you break things down. Very easy to understand.
@BMoDev
@BMoDev 3 жыл бұрын
delayed answer, but thanks man I appreciate ya 🙏
@IceCream-sb7lc
@IceCream-sb7lc 3 жыл бұрын
Supporting your return by watching the entire ad and this entire tutorial. I request a gourmet dialogue system tutorial with decision making please.
@BMoDev
@BMoDev 3 жыл бұрын
The real mvp 😭
@jehriko7525
@jehriko7525 2 жыл бұрын
THANK YOU! Been struggling with this because I suck at coding but this helped a ton, def subbing.
@crazyconan28
@crazyconan28 2 жыл бұрын
Thank you BMo for your awesome videos. This was a awesome exercise to follow!
@Josue-Arreaga
@Josue-Arreaga 2 жыл бұрын
honestly you deserve it. This video, the last one I saw, the one before it. Subscribed
@Luluskuy
@Luluskuy Жыл бұрын
This... Simply short and sweet. SUBSCRIBED!
@thepolygonpilgrimage
@thepolygonpilgrimage 3 жыл бұрын
Brilliant work! Thanks so much for sharing and not wasting time. Love it. Subbed for more.
@SkeletalDweller
@SkeletalDweller Жыл бұрын
This is exactly what I needed, thank you so much!
@mortalvoidstudios
@mortalvoidstudios 2 жыл бұрын
Thank you so much! This was exactly what I was looking for.
@barrelbrothers6896
@barrelbrothers6896 10 ай бұрын
Thank you man! Super detailed/concise tutorial 10/10.
@eileeng2492
@eileeng2492 3 жыл бұрын
Finally, you're back. Great! Keep them coming
@bobgala4494
@bobgala4494 3 ай бұрын
ty
@quarteroclock1365
@quarteroclock1365 2 жыл бұрын
man, thank you! this was exactly what i was searching for!
@BMoDev
@BMoDev 2 жыл бұрын
happy to hear it!
@BraedensStuff
@BraedensStuff Жыл бұрын
this was just perfect for what I needed
@iwoMalki
@iwoMalki 10 ай бұрын
Nice simple and fast! Lovely!
@Woots
@Woots 2 жыл бұрын
Wonderful tutorial! Thanks!
@deheane
@deheane Жыл бұрын
Muito obrigada, em 5 minutos você ensinou mais que tutoriais extremamente longos :D
@odessialiu3552
@odessialiu3552 4 ай бұрын
This is so clear and useful!
@deadbroadcastpc
@deadbroadcastpc 3 жыл бұрын
He’s alive!!!!! Glad to see you back man
@BMoDev
@BMoDev 3 жыл бұрын
Thanks man, will try to get back into a rhythm 😅
@homiek5974
@homiek5974 2 ай бұрын
one of the best tutorials, thanks brother
@nickolasmachado9274
@nickolasmachado9274 Жыл бұрын
Thank you for this tutorial!
@Noth0ng82
@Noth0ng82 Ай бұрын
thank you, your tutorial is really helpful
@neffthepanda
@neffthepanda Жыл бұрын
Great video! Gonna use this for my NPCs.
@ozgurgurbuz
@ozgurgurbuz 2 жыл бұрын
Thanks for this short tutorial. 😊
@BMoDev
@BMoDev 2 жыл бұрын
You're welcome!
@CASMANWHAT
@CASMANWHAT 3 жыл бұрын
Yesss!!!!!!!!!!! Welcome back love your tuts
@BMoDev
@BMoDev 3 жыл бұрын
💗
@Devlper_
@Devlper_ Жыл бұрын
Thanks For this Great Tutorial Bro
@GrimCrayontheWraithLord
@GrimCrayontheWraithLord 6 ай бұрын
OMG! I WAS TRYING OTHER TUTORIALS, AND THEY DIDN'T WORK FOR ME, BUT THEN I COME HERE AND IT WORKS FIRST TRY!!! This is EPIC!!!
@BMoDev
@BMoDev 6 ай бұрын
You're epic
@GrimCrayontheWraithLord
@GrimCrayontheWraithLord 6 ай бұрын
@@BMoDev :O
@maayandighorker6930
@maayandighorker6930 2 жыл бұрын
Great video, thanks! definitely subbing :)
@imabean9710
@imabean9710 Жыл бұрын
Thanks for helping me to make some task game programming
@shang_psycho7414
@shang_psycho7414 2 жыл бұрын
Thanks! This helped a lot. Something cool to add would be that sounds that play while someone's talking like Undertale.
@HivemindZalgo
@HivemindZalgo Жыл бұрын
Jesus, why is it so hard to do something like what u did? Other videos take up 20-30 minutes of my life with extra stuff that's unnecessary but if I don't add the code will break. Thanks a lot!
@happyghoststudios4237
@happyghoststudios4237 Жыл бұрын
Such a great video!!! Thank you!!!
@BMoDev
@BMoDev Жыл бұрын
Thanks
@bobwinberry
@bobwinberry Жыл бұрын
Fantastic - thanks!
@fatihbtw5288
@fatihbtw5288 Жыл бұрын
thx you so much, great video
@jjbc5059
@jjbc5059 9 ай бұрын
I love this tutorial. Simple. Well explained. Short. It works. There's nothing else you can ask for. Good job m8!
@GemGameDev
@GemGameDev 11 ай бұрын
This was effective.. thanks!
@Eduard02834
@Eduard02834 2 жыл бұрын
Thanks really helpful and less time !!!!
@perttihakala9847
@perttihakala9847 2 жыл бұрын
awesome! just the thing i need! :3
@wicksley
@wicksley 11 ай бұрын
Awesome thank you :D
@EnemyOTS
@EnemyOTS 2 жыл бұрын
LMAO impressive! 5 minutes indeed. Great tutorial
@BMoDev
@BMoDev 2 жыл бұрын
Appreciate ya
@mediamermaid333
@mediamermaid333 Жыл бұрын
Thank you!!
@hejhejhej952
@hejhejhej952 6 ай бұрын
Thank you kind sir!
@m4v3n95
@m4v3n95 2 жыл бұрын
Really helpful!
@BMoDev
@BMoDev 2 жыл бұрын
Love to hear it
@lejocarry
@lejocarry Жыл бұрын
Really good :)
@ginoantenucci6424
@ginoantenucci6424 Жыл бұрын
I am surprised it wasn’t one of those videos that has no talking and just coding at 3x
@vain_rafael2868
@vain_rafael2868 8 ай бұрын
2 years old, still very useful!
@PRAVEENKUMAR-xg6qe
@PRAVEENKUMAR-xg6qe 2 жыл бұрын
now i am in a good mood
@ilypavan
@ilypavan Ай бұрын
Thank You.
@stevenhays6816
@stevenhays6816 8 ай бұрын
Top notch vid bloke
@infosource3153
@infosource3153 2 жыл бұрын
Excellent
@someobscuremusicchannel
@someobscuremusicchannel 2 жыл бұрын
the red x in the corner was killing me man
@nevimkde9537
@nevimkde9537 Жыл бұрын
Absolutely love this video!!! Helped a lot, but I have a question. If I wanted to make multiple instances of waiting function for some reason code doesnt execute them at all. If I have multiple IEnumerators nor If I have If function in one IEnumerator, there it will only execute the original and if I change the text appearance to that another if statement it will completely skip any dialogue at all (my main reason of doing this if because the character not always speaks at same speed e.g. if he is surprised he will swallow some of his words or in cutscener or non-interactable dialogue which will appear and dissapear of its own). Thank you if you are willing to help me!
@isaacwiseau8130
@isaacwiseau8130 Жыл бұрын
this is very good good but with all the zooming around I wish I could see more of the Unity window to see other values while working at my own pace
@Bittergiggle_gaming
@Bittergiggle_gaming Жыл бұрын
Thanks! This helped me with Normal Kindergarten! Now Nabnab, Chef Chick, Hopping Bun, Etc, Can Now Say What I Wanted It To Say!
@karnecita
@karnecita 7 ай бұрын
gracias, sos un capo, excelente tutorial 10/10
@karnecita
@karnecita 7 ай бұрын
using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; public class Dialogue1 : MonoBehaviour { public TextMeshProUGUI textComponent; public string[] lines; public float textSpeed; private int index; // Start is called before the first frame update void Start() { textComponent.text = string.Empty; StartDialogue(); } // Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { if (textComponent.text == lines[index]) { NextLine(); } else { StopAllCoroutines(); textComponent.text = lines[index]; } } } void StartDialogue() { index = 0; StartCoroutine(TypeLine()); } IEnumerator TypeLine() { foreach (char c in lines[index].ToCharArray()) { textComponent.text += c; yield return new WaitForSeconds(textSpeed); } } void NextLine() { if (index < lines.Length - 1) { index++; textComponent.text = string.Empty; StartCoroutine(TypeLine()); } else { gameObject.SetActive(false); } } }
@TegridyMadeGames
@TegridyMadeGames 3 жыл бұрын
You're amazing...
@BMoDev
@BMoDev 3 жыл бұрын
@minecraft_top_game
@minecraft_top_game 25 күн бұрын
Thank you
@smarttarded
@smarttarded 9 ай бұрын
This is actually perfect for silent protagonists who isn't expected to respond to NPCs
@Skyblade22
@Skyblade22 3 жыл бұрын
this the good stuff
@macros3570
@macros3570 3 жыл бұрын
thank you so so much
@BMoDev
@BMoDev 3 жыл бұрын
@byTrident
@byTrident 2 жыл бұрын
thanks man
@BMoDev
@BMoDev 2 жыл бұрын
You bet
@arrexu01
@arrexu01 2 жыл бұрын
Question. How would I be able to mix this with a multiple choice dialogue system?. Like, say my player would have a voice line, then naturally the npc would respond, but only once and the conversation is done. So what I mean is, how can i transition between both?
@potantirittisak8494
@potantirittisak8494 3 жыл бұрын
Thank uuu
@yankates3752
@yankates3752 Жыл бұрын
thanks a lot
@RakeBye22
@RakeBye22 Жыл бұрын
thank you
@MayKayy
@MayKayy 3 жыл бұрын
Thanks
@madpenguin58
@madpenguin58 3 жыл бұрын
Hi @BMo! Is there some kind of way that one could add some kind of trigger collider on something like a sign or NPC and have the character hit a button like the space key in order to start the dialogue instead of having it start at the beginning of the game? I have tried some things myself but I just can't figure this one out. Thanks!
@BMoDev
@BMoDev 3 жыл бұрын
Yeah 100%, you just need that trigger to execute the StartDialogue method. I have an "Interaction" tutorial, you can use the principals in that to call the StartDialogue Method! kzfaq.info/get/bejne/mbKqepR5qcmxZKc.html
@madpenguin58
@madpenguin58 3 жыл бұрын
@@BMoDev Ok! Thank you very much! I was also wondering (sorry I have so many questions. I should probably just get better at code on my own.) if there was some kind of way to implement a response, and have the dialogue loop back to the beginning every time you play it. Thanks! I have been following a bunch of your 2D tutorials and am learning a lot about making games!
@IvanThGreat
@IvanThGreat 2 жыл бұрын
@@madpenguin58 Hello, I would like to ask how did you get it to work with the Interact system?
@cricadev
@cricadev 3 жыл бұрын
Hey bro, how can I do this but with the new input system from unity, GetMouseButtonDown, doesn't exist anymore.
@ikizlerlebirgun7119
@ikizlerlebirgun7119 3 жыл бұрын
I subscribed in 5 minutes
@BMoDev
@BMoDev 3 жыл бұрын
👏Thats how its done
@berkepeksen5584
@berkepeksen5584 Жыл бұрын
good stuff
@NAgamerOfficialYT
@NAgamerOfficialYT Жыл бұрын
is there a way to make it pause for a small moment for stuff like commas or something like that?
@sarmsaklomlet5852
@sarmsaklomlet5852 Жыл бұрын
thanks:)))
@animationanimator5143
@animationanimator5143 Жыл бұрын
Is there a way so that certain elements aren't said in the dialogue box until the player reaches a certain point?
@charm558
@charm558 Жыл бұрын
ty so mch
@MadGeekGirl
@MadGeekGirl 2 жыл бұрын
Is there anyway to add this to multiple game objects and have the dialogue system come up when the game object is interacted with in some way? I've tried so many tutorials and methods and have been stuck for days.
@IGotNoNameZ
@IGotNoNameZ 29 күн бұрын
Did you find out. Same problem lol
@toasterdev8329
@toasterdev8329 3 жыл бұрын
exactly what i neded
@BMoDev
@BMoDev 3 жыл бұрын
Happy to hear it!
@trstation3172
@trstation3172 2 жыл бұрын
@@BMoDev hello, the code worked fine, but when I press the left button of my mouse, the dialogue speeds up and my texts are not visible, it goes directly from 1 to 10.
@dovmandev
@dovmandev 5 ай бұрын
I expect from you a package solution for medium-sized projects like this in the video
@triggerdc3gaming617
@triggerdc3gaming617 2 жыл бұрын
great video! but does anyone know how to have different lines of text for two separate NPCs? my brain is fried and idk how to pull it off
@awawa5594
@awawa5594 10 ай бұрын
How do you give control back to the main game after dialogue ends? I'm having difficulties wording what I mean but after the dialogue runs using this method, I want to then get objects to show or be able to click on buttons but I don't want to add that code directly in the Dialog Manager as it'd make it messy and not specific to the dialog but I don't know how else to do it?
@HuGGmaN
@HuGGmaN 2 ай бұрын
Genius
@lufttaffy
@lufttaffy 2 жыл бұрын
thanks
@BMoDev
@BMoDev 2 жыл бұрын
No u
@macaaris1018
@macaaris1018 3 жыл бұрын
Nice👍 After So long period?
@BMoDev
@BMoDev 3 жыл бұрын
Yes, finally :)
@jordanthebestlass8483
@jordanthebestlass8483 2 жыл бұрын
how do i keep the the text from moving when i have it's alighnment centered?
@sl4ve576
@sl4ve576 8 ай бұрын
That's cool, but how do I link the dialogue to activate by talking to an Npc?
@310thebank
@310thebank 2 жыл бұрын
Dialogue I dont have TextCompunet space for drag to it what happen using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; public class Dialogue : MonoBehaviour { public TextMeshProUGUI textComponent; public string[] lines; public float textSpeed; private int index; // Start is called before the first frame update void Start() { textComponent.text = string.Empty; StartDialogue() } // Update is called once per frame void Update() { } void StartDialogue() { index = 0; StartCoroutine(TypeLine()); IEnumerator TyoeLine() { foreach (char c in lines[index].ToCharArray()) { textComponent.text += c; yield return new WaitForSeconds(textSpeed); } }
@siddeshas8193
@siddeshas8193 2 жыл бұрын
how you sloved bro after that same problem I'm also facing
@AIIied.Mastercomputer
@AIIied.Mastercomputer 2 жыл бұрын
@@siddeshas8193 Still need help? Because I found a code that works.
@section8entertainment961
@section8entertainment961 Жыл бұрын
you spelled TypeLine wrong in your IEnumerator function. you also have no ; after StartDialgoue in your Start function.
@yanz3e14
@yanz3e14 3 жыл бұрын
hi how do i move to another scene whenever there is no more dialogue?..can you help ?
@dralexander6211
@dralexander6211 Жыл бұрын
Hello I was wondering if you could help me I would like to know how to stop the text from showing up when the game starts. I would highly appreciate it if you could give me some advice :)
@muttlymartin2621
@muttlymartin2621 Жыл бұрын
ngl i got a really odd error when goin though his steps, its displaying 0 which i suspect is the index then flashes each character after the number. ive double checked my code to his but i dont understand wondering if someone might of had the same issue?
@Caloby
@Caloby Жыл бұрын
Good Video x2
@gopogong6685
@gopogong6685 Жыл бұрын
Yes mmm Good Video
@tomo8940
@tomo8940 Жыл бұрын
Anybody know why am I getting "Object reference not set to an instance of an object Dialogue.Update() (at Assests/Dialogue.cs:26"? It's for a college project :(
@connorwilson-long1336
@connorwilson-long1336 2 жыл бұрын
Any easy way to reset this when coming back for more dialogue? It works if I just set the index to 0 and change the dialogue lines, but it is blank at first and when it doesn't do the animation for the first line either.
@Tea-qk6ii
@Tea-qk6ii 2 жыл бұрын
hey u gotta do an if/else statement to say something like if talked to then (else) this action can happen
@gopogong6685
@gopogong6685 Жыл бұрын
Good Video
@Caloby
@Caloby Жыл бұрын
very yes good
How to Make A Simple HEALTH SYSTEM in Unity
7:15
BMo
Рет қаралды 58 М.
How to make a Dialogue System in Unity
16:19
Brackeys
Рет қаралды 919 М.
Я обещал подарить ему самокат!
01:00
Vlad Samokatchik
Рет қаралды 9 МЛН
Они так быстро убрались!
01:00
Аришнев
Рет қаралды 1,6 МЛН
A little girl was shy at her first ballet lesson #shorts
00:35
Fabiosa Animated
Рет қаралды 15 МЛН
НРАВИТСЯ ЭТОТ ФОРМАТ??
00:37
МЯТНАЯ ФАНТА
Рет қаралды 8 МЛН
UNITY 2D NPC DIALOGUE SYSTEM TUTORIAL
7:52
diving_squid
Рет қаралды 52 М.
Learn Ink (video game dialogue language) in 15 minutes | Ink tutorial
14:47
Shaped by Rain Studios
Рет қаралды 59 М.
Creating a Flexible Dialogue System With Unity 2D
10:17
Semag Games
Рет қаралды 73 М.
I Made My First Game in Godot in 3 Weeks...
26:21
Jack Sather
Рет қаралды 279 М.
Making Dialogue with Inky and Unity Tutorial
12:16
The Phantom Game Designs
Рет қаралды 50 М.
The Future of Game Development
8:58
Brackeys
Рет қаралды 1,2 МЛН
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 699 М.
Undertale DIALOGUE|CUTSCENE in Unity (Episode 1)
16:33
Pandemonium
Рет қаралды 64 М.
Я обещал подарить ему самокат!
01:00
Vlad Samokatchik
Рет қаралды 9 МЛН