How to Create a Conversation
Documentation
Documentation
Creating a conversation is the most fundamental action when creating new dialogue using this tool! To do so, we must create a Conversation Tree Asset which will store all of our graph's data.
Go to the "Resources" folder, right-click -> Create -> Dialogue System
-> New Conversation Tree.
Rename the conversation tree to your desire. To open the conversation in the graph view, simply double-click on the conversation tree. Once you double-click on the Conversation Tree, a new and blank graph window should pop up. I call this graph the "Dialogue Editor".
We are now working in the “Dialogue Editor” window. Right click OR press the space bar to create a new node. You always want to start a conversation tree with the Start node.
Create any amount of nodes you want. I’ve gone ahead and created a simple setup with one of each node type. Make sure that whenever you want to end a conversation you always link it to an End Node or else errors may occur.
Now connect the nodes to each other. An output port has to connect to an input port. For the dialogue node, click the “Add Choice” button at the top right to create a new output port.
Output Ports are found on the right side of each node.
Input Ports are found on the left side of each node.
Note that the "Start" and "End" nodes have only 1 port each. The start node is the reference to the beginning of the conversation so we cannot connect anything to it. Similarly, the end node is a reference to the end of a conversation, so we cannot connect anything after it.
Fill in the different fields for the dialogue node. The event node currently does not work. You can also change the End Node Type to another function if wanted, but I will leave it to just end the current conversation.
Save the graph using the button at the top left toolbar. The graph and all its node data are now saved into the Conversation Tree Scriptable Object. Make sure to save every time you make a significant change!
The language we’re using at the top right is set to English by default. If we wanted to, we could change it to other languages we defined in the DS_LanguageType.cs script. Before you change the language though, make sure to SAVE your current changes or else they will not be present after switching back.
To load in a new language in the Dialogue Editor, simply click the language from the drop-down and click "Load".
To change the language used in-game, navigate to the "Language Controller" game Object. If you do not have this object,
Right-click in the hierarchy -> Create Empty
Now give it the name "Language Controller" and in the inspector, click "Add Component". Search for the "DS_LanguageController" script and click on it. Now you can set the in-game language to the selected language. You can also change the language during run-time and it will update live.
If you want to add more languages to your game, navigate to the "DS_LanguageType.cs" script located in the:
Dialogue System -> Scripts -> Dialogue Editor -> Runtime -> Enums folder.
Now feel free to add the names of any language! Make sure to add a comma after every language, but for the last one in the list make sure there is no comma.
We are finished using the “Dialogue Editor” window. For any NPC or regular object you have in your scene, drag in the Interaction Point Prefab as a child of the object. This will allow the player to interact with that point. It can be placed anywhere in the world!
Click on the Interaction Point Object and look at the inspector. Here we can customize our different settings including the interaction radius as well as select the specific conversation tree that we want. I’m setting it to the Conversation Tree created for this tutorial:
Now Click the play button, go up to your NPC/object, and click E to see the dialogue work in action! Clicking “Hello World” will end the conversation and the player can continue to move.