Dialog Controller

Dialog ControllerThe Dialog Controller has been designed to display dialog popups filled with textual data at the locations where a particular dialog is taking place.

Data is read in from text files within the Resources directory within the Unity project folder. The text files are sorted and separated based off the name of the desired game object given within it’s own script behavior. Also, within it’s own script behavior, this is where its initial dialog state is set, this determines the initial read in dialog. Resources InformationAs seen within this image, this shows how what I call the NPC (Non-Player Character) game objects dialog data is sorted to be picked when needed for the read in NPC’s particular dialog state.

This data is picked based off the attached Dialog Controller script attached to the NPC. The Resource Data Location is used to determine where the text files are located within the Resources folder. Also, and importantly, the Initial Dialog State locates the initial dialog text within the text files, I will explain this more in depth later on. Dialog Game Object InfoThe next image shows the inputs I gave the NPC Behavior script and Dialog Controller script based off my example for the individual NPC objects. Within my scene initializing script I dynamically create and change the Name attribute within the NPC Behavior script.
Dialog Controller

Dialog is created with simple text statements and implemented built in functions to either send dialog to a different game object or to change the dialog state of the current NPC a particular dialog is attached to. These are currently the only built in functions, but more will be coming down the road, such as sending a dialog statement to multiple game objects at a time. As seen in the next example, this text file called Pondering.txt represents an NPC with the Name value of Pondering within the NPC Behavior script. Text Data ExampleThe Start line represents the Initial Dialog State of the NPC object, the next line is the first line that is displayed, Pondering ExampleMain Player Responsewhich would look like the image on the left, the blue character represents the main player. As you can see, the three dots “…” animate between “.” -> “..” -> “…” repeating this, indicating that there is another dialog statement in this particular dialog. To both advance and initialize a dialog statement the Activator Key: SPACE by default must be pressed. The [R_MainPlayer] tells the system to send the dialog statement to the MainPlayer object, which MainPlayer is the name of the main player’s game object. Continuing on, the next statement in the dialog is sent to the Pondering NPC object, where finally the [CS_NewStart] changes the Pondering NPC object’s Dialog State to NewStart. Take note of the space between the individual dialogs, this is important to separate between dialogs.

Leave a Reply

Your email address will not be published.