Posted December 19, 2024 by Aykou
The first part of my work on this project was building the dialogue system, which was a huge learning experience and went through quite a few iterations. Let me break it down step by step and reflect on how things progressed.
The first thing I had to do was create a basic dialogue system. At its core, this was about displaying text and allowing the player to move through dialogue panels. Honestly, it felt pretty straightforward at first:
DialogueManager
script that handled displaying dialogue text and moving to the next line when the player clicked a button.
At this stage, it was basic but functional. The problem, though, was that it wasn’t very connected to the rest of the game. It didn’t interact with quests or any larger systems, and every NPC would need its own dialogue logic manually set up. It worked for testing, but it needed to evolve.
Next, I worked on tying the dialogue system into the quest system, which was a pretty big upgrade but also brought a lot of challenges. The goal was to make it so:
To do this, I added fields to the DialogueNode ScriptableObject, like:
triggersQuest
: A boolean to check if the node triggers a quest.
questToTrigger
: A reference to a QuestData
object.
ActionType
: An enum for specifying whether to start or progress a quest.
I also updated the DialogueManager
to handle these fields. If a dialogue node had a quest to trigger, it would call the QuestManager
to either start or progress the quest. This made the system feel a lot more connected to the overall gameplay, but getting it to work with the existing systems was tricky.
For example, one of the challenges was ensuring the quest system wouldn’t break if a node tried to progress a quest the player wasn’t on yet. I ended up adding checks in both the QuestManager
and DialogueManager
to handle this gracefully.
After getting the dialogue system to work with quests, I needed to make it easy to reuse for multiple NPCs. This led to creating an NPC prefab. Here’s how that went:
NPCInteraction
script to handle clicking on an NPC to start their dialogue.
DialogueManager
and pass the NPC’s starting dialogue node.
QuestManager
.
BoxCollider
to detect clicks.
This part felt like a big milestone because it finally made the dialogue system feel modular and reusable. Now I could easily drop new NPCs into the scene and hook them up with their dialogue and quests.
At this point, I wanted to improve the workflow for writing and editing dialogue. Manually creating and connecting DialogueNode ScriptableObjects in the Inspector was getting tedious, so I tried building an in-Unity dialogue editor tool. The idea was to:
Unfortunately, this didn’t work out as planned. I ran into a lot of issues with Unity’s UI system and figuring out how to save and load nodes dynamically. While I got a basic prototype working, it wasn’t stable or polished enough to use. I’ve decided to postpone this tool for now and come back to it later when I have more time to focus on it.
Looking back, the dialogue system has come a long way. It started as a simple standalone system and now feels like a fully integrated part of the game, working with quests and reusable NPC prefabs. I’m happy with how it’s turned out, but there’s always room for improvement. For example:
If anyone has tips or ideas for improving dialogue systems, especially with Unity, I’d love to hear them. Thanks for reading!