Unreal Engine 4 - The Easiest NPC Dialogue Tutorial EVER

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] what is up guys today i'm giving you three ways to begin your conversations with npcs where the one you'll choose will be very much dependent on your game we will be diving into npc dialogue in the next episode but i thought it would be better if i split these two tutorials up before we start a quick thank you to my patreons you guys are awesome so thank you okay let's jump into this so the first thing we're gonna do is duplicate our player character so duplicate it and call the new one bp underscore npc then we're going to create a blueprint interface so right click under blueprints blueprint interface call this npc interact and the last thing we're going to create is a widget so right click under user interface widget call this black screen pop so we've got our npc our interface so we can interact with our npc and a widget to flash the screen to black let's double click on our widget to open it up pull an image onto the screen and change its color and opacity to black make it big so it can fit on all different screen sizes and then let's set the anchor to centered middle so it scales down from the center in the bottom left create a new animation track and call it fade in out select it and then add a track for our black image on our image add a new track called render opacity set render opacity to zero at time 0 and then a keyframe will appear move the time to 0.2 seconds and change the render opacity to 1. then move the time to 0.4 seconds and change the render opacity back to 0. cool we've made the animation now let's jump into the event graph off the event construct bring in a play animation mode then ctrl drag in our animation from the left hand side plug this into the play animation node and connect it into the construct okay we've got our widget with animation now let's jump into the interface let's create a new function and call it activate dialog a blueprint interface allows us to call events without a direct reference meaning we can call an event inside our npc without casting to that specific npc now hop into your third person character bring in a key press of your choice i'm just going to use the e key bring in a get overlapping actors node and inside it select actor pull off this and bring in a for each loop with break then pull off the array element and bring in a does implement interface and select our npc interface hold b and click to bring in a branch and connect all of this up then off the branch is true we're going to call our activate dialog interface event and connect our array element into this off the activate dialog we're going to put it into the for each loop break double click to add a reroute node so we've used this setup before in our picking up weapons tutorial all this does is scan for any overlapping actors if we're overlapping one check if they implement an interface and if they do call the activate dialog blueprint interface event for anyone using this setup for their pickup weapons what you can do is put your other interface and event coming off the branches false like so now let's jump into our npc blueprint and hop into the viewport delete the camera boom and follow camera then let's add a text render and place it just above the npc's head with the text saying press e to chat then let's add a box collision directly in front of the npc this is where your character will need to stand to interact with the npc and then we're gonna add a cone attach this cone to the mesh and scale it down in the detail section set hidden in game to true and set collision to no collision this cone is just a reference point of where we're going to teleport the player to stand and lastly add a camera component this will be the camera the player looks through but don't worry about moving this into position we'll do this with a variable now i want you to jump into the construction script and for those of you who don't know what the construction script does it's basically an event graph which runs before the game is played so all these nodes will fire off until we play the level and we can use this to tweak how our blueprint looks so let's control drag in our camera and our cone pull off the camera and set relative transform then pull off the transform promote to variable and call it camera transform make sure you check instant editable now pull off the cone and set relative location pull off the location and promote a variable call it player location and check instance editable then connect these nodes coming off the construction script so now we've done this for each npc we can change the transform of the camera that the player looks through and we can change where the player will stand during conversation this allows us to create different npc conversations without having multiple blueprints so after you drag in your npc you can change these values in the detail section but for now just type in these values for camera transform pause the video now and type these values in for player location put 159 for the y-axis now what i need you to do is hop into the event graph and then hop into the class settings where it says interface on the right hand side add the npc interface we just made and compile now i need you to hop into this video's description click on the blueprint nodes link when it opens copy all the nodes and jump back into your unreal project paste them into the event graph when they're pasted in compile and make sure you've got no errors by swapping over any names to names related to your project so third person character should be your character's name and make sure the widget is set to your black screen widget then delete the player adjustment event call and then recall it we'll also have to redo the timeline so double click to open it up add a float track set the length to one second long and shift click twice to bring in two points click on the first one and set it to time zero value zero then click on the second and set it to time one value one then we can go back into our event graph plug the track into the two alphas which are appearing red and compile so what all these nodes do so starting from the top when we overlap the mpc we set the text render we made to visible then we turn it back to hidden when we end the overlap when our character overlaps the npc's box and presses e the event activate dialog blueprint interface will trigger this will call the player adjustments event and set the text render back to hidden down here is our player adjustments event which sets our input motor ui only which disables our movement and then it's up to you guys to decide which route you want to go down these are the three different methods i showed you at the start of the video so i won't be explaining what each one does as all the nodes are pretty self-explanatory but to sum it up we're using the set view target with blend node to swap our camera to the npc camera and then we're moving our character to the location of the cone reference so have a play around with all three methods and try changing your camera transform and player location inside the npc details in-game and that's it for today folks in the next episode we cover the actual dialogue but before you go if you enjoyed this video if you could help me out with a like comment subscribe patreon marketplace asset purchase or anything that would be so awesome thank you guys so much for watching and i'll see you all next time [Music] you
Info
Channel: Beardgames
Views: 71,346
Rating: undefined out of 5
Keywords: Unreal Engine 4, NPC, Talking, Game Development, Unity, Dialogue, Free Download, Free System, Epic Games, Unreal Engine 5, Tutorial, Early Access, Lumen, UE5, UE4, Nanite, unreal engine, ue4, game development, Beard games, Beardgames, unreal engine 4, unreal engine 5, epic games, ue5, gamedev, unreal engine 2020, game dev, unreal engine tutorial, unreal, game developer, indie gamedev, unreal engine 5 early access, unreal engine npc dialogue, ue4 npc dialogue, ue5 npc dialogue
Id: 3uHQRpK2jkE
Channel Id: undefined
Length: 9min 4sec (544 seconds)
Published: Mon Apr 26 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.