Intro to Dialogue Tree 3: Queries and Events Tutorial (Outdated - See Description)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi my name is Zach and in this tutorial for dialog tree we're going to take a closer look at dialogue queries and events if you don't already know dialog tree is a free plugin available on the unreal Marketplace that offers an easy to ous system for creating and editing in game dialogue we'll start by reviewing what queries and events are as well as how they fit into the dialogue workflow we'll then create a short dialogue together that will help us to explore creating our own custom queries and events we'll be picking up from where we left off with the quick start and editor tutorials so if you haven't seen those yet I would highly recommend that you check them out before continuing let's start with a short recap what are dialog queries and events and how do they fit into the dialog workflow to put it simply queries and events are a way for you to let your game World talk to your dialogues and vice versa taking queries first these allow your dialogue to fetch information from the game world let's say you're making a role playing game the player has a bunch of statistics including intelligence and you want to gate certain dialogue options behind a particularly high or low intelligence in that situation you could make a dialog query to check the intelligence score of the player you could then use that query to Branch over the player's intelligence score events are the flip side of queries rather than fetching information from outside they use the information in dialogue to do something to the game World take our role playing example let's say you want to give the player a quest when they go down a spefic specific path in dialogue to do this you would simply make a dialogue event to add the quest and add it to an event node at the appropriate point in the conversation the big Point here is that queries and events give you the flexibility and control you need to integrate dialogue into the world of your game if you want information from outside the dialogue you can make a query to get it if you want your dialogue to have an impact beyond the confines of the conversation you can create an event with a desired effect before we go digging into how we can make our own custom queries and events I want to take a moment to talk about the default queries provided as part of the plugin these are slight exceptions to the rule discussed above in that rather than retrieve information from outside the dialogue they retrieve information from the dialogue itself first up we have the node visited query this one is mostly self-explanatory it asks you to specify a node in the graph if that node has already been played in conversation the query returns true otherwise it returns false this is useful for ensuring a key speech or event plays only once or for providing a different speech on subsequent passes through the conversation the speaker found query is a little more complicated if you think back to the editor tutorial you may remember that the dialog tree asset expects you to provide it with the speaker components for its speaking roles if you don't provide all the necessary speaker components the dialogue will continue as normal until it encounters a speech node whose associated speaker component is missing at that point it will simply end the conversation but let's say you're making a party based game where the player might have a wide variety of different companions with them at any given time we'll call one of these companions Juliet if Juliet is in the player's party during a particular conversation we want her to make a comment but we can't know beforehand if she's there that's where the speaker found query comes in it allows us to check if Juliet's speaker component is present if it is we play Her speech if not we divert around it to continue the conversation there are also a handful of included events reset node visits is the counterpart of the node visited query this event asks you to specify a node in the graph to Mark as unvisited reset all node visits is the nuclear version of the same thing instead of marking a single node unvisited it marks every node in the dialogue unvisited effectively resetting the dialogue to its initial State finally dlge log to screen is an event I created to help with debugging it's the equivalent of blueprints print string method allowing you to log a message to the screen in fact it actually calls blueprints print string method onto the hood with that out of the way let's take a look at how we can create our own custom queries and events to do this we'll set up a simple dialogue as pictured here the dialogue imagines that the player is a child on a road trip with a parent being a creature of great patience the player will continually ask Are We There Yet the parent will tell the player no little does the parent know that asking if we're there yet actually does make us get there faster when the player has asked five times the answer changes to yes and the dialogue ends let's take a moment to dig a little deeper into how this dialogue fits together first up we have the parents introduction this is just a speech node with an input transition in other words the parent NPC will say the speech and then wait for a response the provided response is a speech node with an auto transition it says are we there yet because it has an auto transition selecting that response will play the speech and continue on down the chain there's no audio to play so we effectively continue immediately the next Noe in line is an event node we want to populate this with an event that increases a counter for the number of times the player has asked if we're there yet after that we have a branch node this one will need a custom query to check if the player has asked enough times if so the parent MPC confirms that we've arrived and a final response allows the player to exit otherwise the parent says we're not there yet and a jump node jumps us back up the chain so the player can ask again to put this together we'll need a dialogue query to check how many times the player has asked and a dialog event to increment that value before we can make a custom query we need to make sure we have some information to retrieve in the first place right click in the content browser and create a new blueprint class extending bpc speaker component I'll call mine bpc impatient child speaker opening that new blueprint graph we just want to add an integer variable we'll call it num times asked and give it a default value of zero we'll also make it public so that we can access it directly compile and save now it's time to make our query right click again in the content browser create a new blueprint class and use one of three classes depending on what kind of value we want our query to return speaker query bu returns a Boolean value speaker query float returns a floating point value and speaker query int returns an integer value num sometimes asked is an integer so we'll use speaker query int I'll name mine dgq for dialogue query and then get times asked open up our new blueprint query the first thing we want to do here is override three functions get graph description is valid speaker query and query speaker we'll start with query speaker since it's the simplest of the bunch to explain this function takes a speaker component which will be supplied from the graph and Returns the integer result of the query first we want to try to cast the provided speaker component to our impatient child speaker if the cast fa we'll return zero if it succeeds we'll return the value of num times asked next let's take a look at is valid speaker query this function allows you to protect yourself from Bad data let's say you create a query that that relies on some code object what if you forget to supply the required object in the graph well then you might have a problem you could very well wind up with unexplained bugs just like the equivalent situation in Blueprint is valid speaker query allows you to protect yourself from this situation by defining a condition for your query to compile if the query is not valid according to the terms you define then the dialogue will refuse to compile until the situation is resolved in this case the only value we actually care about is the speaker component this is checked for validity Ware so we can just return true finally we have get graph description this allows us to define the display text associated with our query in the dialogue graph technically speaking you don't even have to override this function by default it will use the class name of your query as its display text but it's cleaner and more informative to create a custom description in this case we want to tell the user that we are checking the times a given speaker has asked a question we'll start by retrieving the speaker socket make sure it's valid and get its name from there we want to format that into the output text and return I'll say speaker times asked now if we open our dialogue asset we can click our Branch node and add a condition note that the text that appears alongside the condition tells us that it's inval valid that's because we haven't given it the information it needs to do its job so let's do that set its query to be our new custom query we'll need to supply the target speaker and because our query returns a numeric value we'll also need to specify a comparison in this case we want to know if the time asked is greater than four with that done the display text should update from invalid condition to the custom description we provided creating a custom event is very similar to a custom query so we'll take it a little faster start by creating a new blueprint class that extends dialog event give it a name I'll call mine dge for dialogue event and then increase times asked open up the new blueprint the first thing we want to do here is create an integer variable I'll call mine increase amount and set its default value to one as mentioned earlier we'll be able to edit this variable directly from the dialog graph next we want to override on play event this is where we'll put the actual behavior of our event we start by casting the speaker component to our impatient child speaker then we increase its num times ass value by the increase amount next up we want to override is valid event this is the equivalent of is valid query as before there isn't really any extra information we need to make the event work so we can just return true finally we'll override get graph description here we want to tell the user that we are increasing the number of times the speaker has asked we also want to tell them the name of the target speaker and the amount we're increasing by start by getting the speaker socket and retrieving the speaker's name from there then we want to format that together with our increase amount to produce the output text I'll say increase speaker times asked by increase amount and I'll feed in the speaker's name for speaker and the increase amount for increase amount compile and save now we can attach our custom event to our event node in the dialogue graph as before the new event will start out telling us it's invalid we need to fill in the Target speaker we could change the value of increase amount but the default value of one that we set earlier is actually exactly what we want with that the display text changes from invalid event to our custom description compile and save the dialogue assuming you're following along from the point we left off in the quick start tutorial we only need to do a couple of things to test our dialogue first we want to swap out the speaker component on the player for the impatient child speaker we created we also want to fill in its display and dialogue name making the dialog name child to match the role in dialogue next we want to open the NPC we created and change its dialogue name to parent we also need to change its owned dialogue to be our new dialogue from there we can press play and test it out out in this tutorial we discussed the purpose of dialog queries and events how to use the provided Noe visited query how to use the provided speaker found query how to use the provided reset node visits and reset all node visits events and how to create your own dialog queries and events future tutorials will cover how to customize the look and feel of dialogue in your project by extending the plugin if this video was helpful to you please give it a like And subscribe so you get notified when videos showcasing new features come out if you have any questions or feedback I would love to hear from you on my Discord Channel and if you're enjoying the plugin I would be Beyond grateful if you could take a few seconds out of your day to leave me a review on the unreal Marketplace finally if you'd like to support further development on the project you can do so on patreon.com links to all of that as well as the plugins documentation site will be posted in the description in the meantime thanks for watching best of luck and happy developing
Info
Channel: UnraedGames
Views: 609
Rating: undefined out of 5
Keywords: Unreal Engine 5, UE5, Dialogue Tree, Dialogue System, Tutorial, Game Development
Id: ENdKu6cPi2s
Channel Id: undefined
Length: 16min 10sec (970 seconds)
Published: Fri Feb 09 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.