Building a versatile dialogue and interaction system


The most important thing in a good graphic adventure is, of course, the dialogues and story. When designing Duck in Town interaction system, we had clear what features were absolutely needed:

  • Conversation between 2 or more characters, names included
  • Ability to give objects to NPC or use objects on top of another
  • Branching dialogues that affect the progress of the story
  • Different dialogues depending on the status of the story

The first thing we decided was which software we should use to write the actual dialogues. We needed a visual representation of the branching, as well as easy editing and organizing. Of course, it should also be open source. The first option was, of course, Twine. However, we also knew Yarn, which adds some nice features to Twine, such as dialogue testing and BBCode buttons. So we decided to use it.

Yarn's dialogue test feature


Since this software just outputs a text file, we needed to implement a parser. We only use basic features of it (we don't use it's integrated scripting, nor inline options or tags). Also, we added a first line on top of every node that shows the name of the character talking. You can check (and use, under GPL3) the parser's code in the repo.

After this, we needed to integrate it in Godot. We created a class (using the new class_name feature in Godot 3.1) called "InteractiveObject". This script is assigned to every interactive object in the game world (NPCs and items). It has inside callbacks for every action that they might perform. This allows to trigger virtually any effect that might be needed (starting a dialogue, giving the player an object, playing a sound, etc). To do this, we only need to override the callbacks with the desired behaviour.

InteractiveObject implementation

This script is assigned and overriden by every interactive object in the world. After this, the last thing we need is a way to actually find InteractiveObjects around the player. For this, we assign an area of interaction to each object, which is found when the player enters it. With all this information, we can fill the action list.

Action list filled with info from near InteractiveObjects

This allows us to have a versatile dialogue and interaction systems, that covers all the needs we listed before and also is easily expandable. Remember that you can check the complete implementation in the source code repository.

Until now we've only shown the zone outside Town's wall, but Town scene is almost finished and we will show it soon!


Get Duck in Town - A Rising Knight

Buy Now$2.99 USD or more

Leave a comment

Log in with itch.io to leave a comment.