How to Make a Simple Dialogue System in Unreal Engine 5

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's up guys welcome to new Unreal Engine 5 tutorial and today I'm going to show you on how to make a simple dialogue system it's going to be a very easy video to follow so let's get started alright so the first thing that we're going to do is basically rate our NPC that's just gonna be standing there so we can interact with it of course if you already have your own NPC or your own AI or whatever you can just use up that guy okay but in my case I'm just gonna create a quickly a new folder um to you know put everything here so uh log and I'm just gonna go ahead and create a new blueprint and in my case it's going to be a character so if in any case I want to move him around you already have the ability to move around I'm gonna call him BP and PC and we're going to go ahead and open here up okay so the first thing I'm going to do is just go ahead and um you know add the mesh I'm basically just going to use the default uh you know mannequin um probably just for example many or whatever I'm gonna Place him correctly so my cd9 okay okay so now that we have our you know character I'm just gonna go ahead and apply his animation uh blueprint so he can just play the Edo animation so it's gonna plug the APB money and you can see that now we have a simple NPC um so I'm just gonna go ahead and drag him into the scene just in front here and I'm gonna go ahead and rotate him facing me like that okay so now we have our MPC on the scene and right now if we you know go into him we cannot do anything of course so we're gonna implement the interaction system so we're gonna make it uh by an interface an interface will allow us to basically um you know connect and interact with other actors without need to cast uh to them or anything like that so it's much more convenient for this uh system for example so we're gonna create a new uh blueprint interface that's going to be called BPI dialog I mean you can call it however you want okay so let's go ahead and open it up and we will see that we um have created a new function we're going to rename this into basically used uh for example talk okay so we will not need any inputs and outputs so we can just compile and save and just go ahead and close this asset down so the next thing that we're going to do is go into our third person character and we're gonna go into the event graph now what we're going to do is that when we hit a key we will search for the actors that are near and then if it's an NPC we will interact with him so I'm going to go down into here and I'm gonna say for example when I press the E key we're going to go ahead and do some things so let's add the E key over here and what we'll do is a um for each Loop and what we're going to do is basically um get or all overlapping actors okay need to rely enters and the thing is that you say okay but then I will be needing needing to be colliding with the NPC well what we're going to do in the NPC is basically add a new sphere collision and this is going to be our trigger zone so this is going to be in the zone that we can interact with him so let's go ahead and increase the sphere radius until for example a hundred well I think it's going to be much bigger 200 so if I'm standing inside we will be able to interact now make sure that is in overlap only Pawn so only the actors will be able to interact with it so now we can compound save and we can go ahead and place the NPC on here Okay so basically when we find our NPC we will uh basically um as uh implements interface cross Implement interface this is going to be our BPI dialog that we have just created before I'm going to make a branch here so if this is true we will go ahead and interact with it now let's go back into our NPC and we need to add our um you know uh interface into it so just go into class settings and in here you can see that we have no not any interface so we can just add one and it's going to be our BPI dialog and there we go okay so what we can do now is from the every element we can use a um Talk which is what we called our function in the interface so now basically it will talk to to whatever uh NPC is colliding with all right so that's cool so the next thing that we have to do is go into the NPC I'm going to go into the event graph now for now we will not need any of this you know events so we can just delete them and the thing is that we're going to create a new uh well a new event for our interface now you can see that we have interfaces down here and we have our talk event so we're just going to go ahead and right click and Implement event so now we have it on here so for now we're going to do a just print and it's gonna just print hello just to check that everything is working so now over here I press e nothing happens but if I were to go ahead and um get closer to the character okay so I forgot something and I started the collation uh it's just colliding with the pawn so what we're going to do is go into the NPC into the trigger Zone and instead of overlap only Pawn is going to be overlap all dynamic okay now it will work press play now we can get uh closer to him and then we can press e and now it says hello as you can see on there so that's cool so what we have to do now is uh set him a set of text that he will basically you know talk to us so for this what we're going to do is create a new variable and this will be overall the dialogue so literally you can just call him that look and basically the type of variable is going to be a string because it's just going to be text now on here in the details we're going to say that's going to be an array because this is going to be basically a list of different texts and we will cycle through them as we go so now we can go ahead and just drag this here and let's say get dialog so now we can delete the print hello so what I'm going to do is also create a new variable and it's going to be our um Talk index for example and then we'll change it into an interior so this will be the number of um like basically which message are we on right now so every time we talk we will cycle through it so what we can do is basically get a copy of one of this with our talk index and I just make sure the talk index is back into single not an array now we can drag it and plug it in and the thing is that right now what we do is every time we press talk what we do is just um get talk index and basically increment it by one so now it will basically give us our array so we're gonna go ahead and pre-string so it will print the message but of course we will you know put it in the UI uh beautiful and stuff but for now this will work for us now make sure that we start with a talk index of -1 here minus one because as you know um the you know arrays start with zero now with one so the first time it's gonna increment it and it will be zero okay and then it will go so on and so on so now we can just press play and you can see if I get well for first of all we have to add some text so click in the dialog and we can add some you know text things over here the first thing is going to be like hello Adventurer or something like that and then um um kill some enemies for me and then like something like it's a dangerous job you know for whatever you like uh so now we're gonna compile and save and now one more press play it can go here and when I press e you will see Hello Adventure kill some enemies for me is a dangerous job exactly what we have written there and it's dynamically uh cycling through them another thing that I'm gonna make sure is that before we do uh access it I'm just gonna make sure uh so I'm gonna add a branch I'm going to make sure that the talk index is um basically um smaller or equal than the dialog length so it will basically not give us a number if the index uh sorry basically if the dialog has finished and you're ready you're also pressing to interact more so there we go we can just come here and he will cycle through it and then when I press e nothing will happen I will not have any errors very important okay so now we can start adding our user interface our UI to display the text on the screen so it's going to grow ahead and create a user interface with your blueprint use the widget and it's going to be a WB um okay so now we can go ahead and open it up now of course I'm going to make it you know real quick just adding some stacks and then later on you can go ahead and customize it as you want to make it and how beautiful you want it to be okay so the first thing I'm going to add is a canvas panel into the hierarchy over here and what we're going to do is just drag some text over here we're going to go ahead and rescale these uh text block as you want so for example let's cover this like this kind of this part of the screen and to make sure that the anchors are on each corner of it so it will resize correctly to the screen size and resolution so now we can for example we can put hello adventurer blah blah blah blah blah whatever right it's just to make sure that everything is fine so you can uh you know put it as you want in my case I'm gonna Center it and also I'm gonna go ahead and there we go like that is okay and I think guys do is also add some blur in the black background so it's a bit um preacher this is things I like to add but of course you know you can put them as you want also the anchors here and then uh where is it where is it blue strand 10 or something like that behind it's like on top maybe five is a bit better and I'm gonna make it you know a bit smaller because I don't have a long test honestly in my dialogue but there we go okay so now we can compile and Save so now we need to synchronize uh basically this text to what you know we're getting from this text over here inner array so basically to do this what we're going to do is Select our text I'm going to rename this into um talk text not the best name but anyway and then I'm going to Mark each variable over here so we can access it from outside so now we're going to go back into our PB and PC and right after this it's created so create widget and the class is going to be the one that we created so uh dialogue and the only player is going to be get player controller great I'm gonna go ahead and uh the first thing is gonna right click promote to variable so we have a reference to it so it's going to be UI and then I'm gonna go ahead and add this into the viewport so it appears on the screen and it will basically create so of course we're only going to do this if UI and get it and right click value to get and only if it's not valid so basically it has not been created before it has been credited before we don't have to go ahead and create it again I'm gonna put this down and then what we're going to do is get our UI and basically we're gonna get our um talk text that we had earlier and then we're gonna set the text over here and I'm gonna make this over here and then put it up so also in a solid it will go over here and now the in text Will basically be well this what we are printing on the screen but now of course we will not be printing it on the screen so we can just go ahead and move this down okay so that's pretty much it we can now save and now if I press play you can go and into the player you can see that I have my widget appear with hello Adventure kill some enemies for me is a dangerous job now we have to go ahead and uh you know this activated when it's finished so on false over here I'm gonna get rid of this because in any more and UI gonna get it and then remove uh from parent this will basically remove the widget so now if we go here I'll Adventure because of my name is for me is a new job and then uh there we go it destroyed it now you saw that I have to you know press it one more time um this is just because uh this instead of being second that's equal it's just gonna be equal and then plug this here and I'm gonna delete this so now it will only do it hello Adventure go to my name is for me is a genius job and it disappears great so we pretty much housing system I'm just gonna make some more little changes to get some more feedback as just for example playing a sound now if you have a like a voice acting you can do it but in my case I don't have a voice acting that's gonna make a simple sound for example you just bottom click it's okay for me now a more thing I'm going to do is go into here and add an image uh this size basically and what to do is just place the anchors over here and some anchors and it's gonna be just a background black color so there's not so much contrast and the alpha is going to be like 0.2 something like that and it's gonna be just above before the it's not gonna go into my NPC press hello so that's it guys if you enjoyed the video and found it helpful I really appreciate a good live video And subscribe to my channel I have lots of Unreal Engine factorials on this one so if you want to check them out go ahead and do so and now yes with what I said bye bye [Music]
Info
Channel: Gorka Games
Views: 81,205
Rating: undefined out of 5
Keywords: games, videojuegos, unreal engine, unreal engine 5, ue5, dialogue system, tutorial, quixel, megascans, unreal engine tutorial, dialogue system unreal engine, ue5 dialogue system, ue5 dialogue system tutorial, ue5 simple dialogue, unreal engine dialogue system, unreal engine 5 how to make a dialogue system, unreal engine how to easily make a dialogue system, ue4, unreal engine 5 easy dialogue tutorial, ue5 tutorial dialogue, how to make dialogue system in ue5, ue5 talk to npc
Id: hbs0xaNOeA0
Channel Id: undefined
Length: 16min 31sec (991 seconds)
Published: Sun Oct 30 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.