Narration System
Last updated
Last updated
The Narration (dialogue) System allows you to define simple dialogues with subtitles that appear at the bottom of the screen, as you have seen in many other games.
This system is not a complete dialogue solution where you can talk to NPCs etc., but a system that allows you to display subtitles for dialogue at certain moments.
Right-click on any project folder and select Create -> UHFPS -> Dialogue -> Dialogue Asset.
To add a new dialogue, click the Add Dialogue button and select the Dialogue 0.
Assign a Dialogue Audio, this can be any audio that contains speech and for which you want to create subtitles.
You can select the type of subtitles the dialogue contains. You can select Single or Multiple.
Single: Select this type if the dialogue audio contains only one sentence or word.
Multiple: Select this type if the dialogue audio contains many different sentences or pauses.
If you have selected the option Multiple, you will have different options. For example, instead of having subtitle settings, you'll see an audio waveform where you can place subtitles at different points in the audio.
Click the Add Subtitle button. This will create a new subtitle point that will be added to the start of the audio.
You can move the subtitle by dragging the vertical white line to where you want the subtitle to appear.
To select the subtitle click on the button below the vertical line.
If you select subtitles, you can define subtitle settings such as who is speaking, the color of the narrator or the subtitle text.
When defining multiple subtitles, make sure that the index displayed in the button below the vertical line is in ascending order. Subtitles are stored in an array, so it is important to add subtitles in order.
This is how it should look like:
To trigger a dialogue, create a new trigger object by enabling the Is Trigger option in the collider and add a Dialogue Trigger component to it.
In the component window you have several settings. The Trigger Type defines how you want the dialogue to be triggered. By a Trigger, Interaction, or by Event.
The Dialogue Type defines where the dialogue audio will be played. Type Local means that the dialogue will be played locally as an NPC narration. Type Global means that the dialogue will most likely be played by the player.
Dialogue Continue specifies how multiple dialogues will be treated. If you keep this in Sequence, the dialogues will be played one by one. If you set this to Event, the next dialogue will be played when you call DialogueSystem.NextDialogue()
.
DialogueSystem is a component that is added to the GAMEMANAGER object and it is Singleton so you can make easy calls.
Dialogue Binder is a special feature that can be used in different ways. It can be used to display the current subtitle in world space or even to synchronize the NPC's mouth with the words.
Dialogue Binder works by triggering certain events that are sent by the Dialogue System, so you can create custom things simply by registering the events you need.
To use the binder, add a Dialogue Binder component to your object.
To use binder events, you can create a new script that will have methods with the parameters specified in the event.
Here are the methods used to display the speech bubble dialogue:
The events will be invoked in each Dialogue Binder component, so you need to check if the binderName is the one you want to use in the script.
Then you can register dialogue binder events on these methods
The Binder Name can be specified in the Dialogue Trigger component.