Dev Log 003 - Dialogue
Dialogue
Link to preview video: https://www.dropbox.com/scl/fi/2sseo6fyippwb1etoorm6/DevLog003.mkv?rlkey=we6ih36...
Dialogue! Allowing a character to talk or narrate is a huge step for me regarding game development. While I have integrated some narrative into my past projects (such as the collectables in Cessation: Terminus 1), live dialogue is an area I have not touched, and so I also have to develop a system that can:
- Show dialogue lines one at a time.
- Show the relevant character name related to the shown dialogue.
- Show the relevant sprite related to the dialogue.
- Type the text out one letter at a time.
- Automatically end when dialogue finishes.
- Allow for impatient players to skip through the dialogue typing effect.
- Work while under stress from impatient player spamming the interact key.
After a lot of work, I got my dialogue system to meet all these requirements! But how did I do it?
How I did it
Fair warning, this is a visual blueprint coding breakdown so it may get a little technical! I'll be explaining everything as simply as I can, however.
Player Code
This code runs on the player character:
I've commented the code to help you follow it, but it simply checks for any active dialogue and if there isn't any when there should now be then a dialogue box is created.
This code checks whether dialogue or a door is in range, and also that dialogue isn't active or a loading screen is active. If the condition is met, the giant "E" prompt appears above the character to tell the player they can interact with something.
The player also holds some empty variables that are written to by other parts of the dialogue system, meaning that the relative dialogue and character info is always held by the player and the player can be cast from in order to read/write this info. Characters are stored as numbers, for example: the player's name will show in dialogue if the relevant line in the integer array reads "0".
Dialogue Triggers
These actors can be placed in the level to create points of interaction that the player can use to trigger dialogue. Each instance is a "child" of the main "parent" template piece, allowing for each trigger to be easily changed without having to go into the coding:
UI Widget Code
This code runs in the dialogue box itself:
This code (split into two images) tells the UI which line to read, and to increment this read line by on when interact is pressed. It won't increment if the typewriter is still typing, instead it will autocomplete the typewriter - this is for impatient players. When there is no more dialogue to show, dialogue ends.
Whilst complicated to explain, put simply: this code checks for the relevant dialogue line written in the player's memory cache. It then displays the relevant entries depending on what stage the line reader is on in the UI variables.
This code plays the fade in animation when the dialogue appears. This code is played backwards in the line reader code to create a fade out effect.
This is the typewriter code. It constantly adds one extra letter into the dialogue box from the text that is supposed to be shown. Once it is done, it changes the "IsTyping?" variable to false. Whilst typing, this variable is set to true. The variable is used in the line reader code to see if the typewriter is busy.
The Product
The final result works flawlessly as intended (as seen in the video). I am very pleased with the outcome of this system, and it seems flexible enough to be used in future projects. Of course, I can go on to iterate and improve the system as I need in the future.
Get Distance
Distance
(2024) Can you remember yourself?
More posts
- Dev Log 009 - And suddenly, the end was upon us!Apr 30, 2024
- Dev Log 008 - General Update and Progress Report!Mar 26, 2024
- Dev Log 007 - Narrative Fully EstablishedMar 12, 2024
- Dev Log 006 - Setting the SceneMar 08, 2024
- Dev Log 005 - Dialogue Part 2, Small AdjustmentsMar 08, 2024
- Dev Log 004 - UI Development, againMar 07, 2024
- Dev Log 002 - Post ProcessingMar 06, 2024
- Dev Log 001 - Development has begun!Mar 06, 2024