How I Created a Dialog System For Unity
How I Created a Dialog System For Unity
For the past while, I've been working on a team of two on an escape room visual novel puzzle game called A Box of Stories. For the game, we needed a dialog system, and in this blog post, I will talk about how I went about making this system.
For context, I had made very basic dialogue systems before. These worked by calling a push method to push dialogue to a dialogue queue. Then, when dialogue was being read, the front of the queue would be dequeued and the characters printed one by one to a dialogue box. This sort of system is great for games that don't have a heavy focus on dialogue systems, but for story driven, visual novel style games, something better is needed. There's also the issue of hardcoding dialogue sequences. That's bad. We don't want to do that, so with this new project, I wanted to use separate dialogue files that would be loaded and parsed by a dialogue parser and printed into a dialogue box by a dialogue handler. Side note: It's very hard to remember to spell dialogue with the British English spelling after all the time I've spent programming this, since convention is to use the American English spelling.
- Playing looping music and ambience to their respected mixer groups and being able to fade in and out.
- Playing one shot sound effects.
- A command to await player input before executing the next command in the queue.
- Commands to set backgrounds or animated backgrounds with the ability to crossfade between them.
- A command to set the character name.
- Commands to handle printing, clearing and continuing of dialogue.
- Commands to define sequences.
- A branch command which can branch to sequences in the same file or in another file.
- Flags which can be added, removed and are automatically saved between sessions.
- Conditional commands to check whether or not a flag has been raised.
- Font commands for controlling the look of text.
- A choice command which creates a choice button with text and runs the specified command when pressed.
- Hiding and showing the dialogue box with or without a crossfade.
- A command to load a unity scene.
- A wait command.
- A sprite command to add, remove and control foreground sprites. For example, character sprites.
- Command aliases such as "say" instead of "dialog" and "name" instead of "character_name".
- Improved audio commands. I think there should be one audio command. A mixer group, whether the audio should be looped or not, starting volume and whether to fade in or out should be specified. I may also use an ID system where a sound is given an ID within the command so it can be referenced later.
- More background transition effects. I will also apply these transition effects to sprites.
- A more robust parser. One current issue is that semicolons, that break commands up, are still counted if they are wrapped in double quotes. I'll need to make better use of regex expressions to handle cases like this.
- A graphical dialogue tree designer similar to Unreal blueprints or Unity's animation system. The underlying systems would be the same. The graphical designer would create a dialogue file.
Comments
Post a Comment