Professional Documents
Culture Documents
Dialogue System: Custom Classes, Arrays, Queues, Loops
Dialogue System: Custom Classes, Arrays, Queues, Loops
A dialogue system is an integral component of most modern games and is a common method of reinforcing
narrative, as well as the underlining game mechanics and associated rule sets.
In this example, we will create a basic structure which allows a series of sentences to be fed back to the user via a
user interface, which can be executed uniquely for a range of interactivity scenarios (objects, NPC’s etc)
This system can be expanded to incorporate further elements if you wish, such as user responses or even a quest
system, but we will keep this linear to understand the basal principles.
We will be looking at a couple of ways to execute this, including the use of arrays, lists, loops and queues.
ACTIVITY:
In a group, discuss the components of a Dialogue system (Objects, scripting and player feedback)
Draw a structured diagram to represent these components and how they will be required to interact with each
other.
BASE COMPONENTS OF A DIALOGUE SYSTEM
We need a way to store the text that will be displayed to the user
We need a way to trigger the text being displayed
We need a way to process the text uniquely for each interaction point
We need a way to display the text
STEP 1: THE UI
We need a simple UI that will
display speech to the player
and allow the user to continue
the dialogue
Create a canvas (if you do not
already have one)
create a panel for the speech
area
create a Text Mesh Pro text
object for the speech
include a button on the panel
to allow the user to continue.
CLASS
Make sure to pop into Unity and allocate the text object and
Dialogue Panel to their respective fields.
STEP 4
We now need to implement all the methods that will control the dialogue.
We need to set up the dialogue first by taking in the custom dialogue class.
We could just pass in the sentences from the Dialogue class, but this will
prevent us from expanding the base class in the future.
Lets create a method called: setupDialogue() that takes in Data of type
Dialogue. Later we will then pass in the dialogue from our interactable
objects.
The sentences currently print out in full, however, it may be more visually appealing if we print out the sentences
letter by letter over a given amount of time.
Follow the tutor tutorial on coroutines and loops.
EXTENSION ACTIVITY