When I undertook the task of creating a short level based off of my previously made Boardwalk Gulch environment, there were two things I set out to accomplish: create a unique character that would inhabit the level, and give the player a sense that this character was interacting with them.
In the last post, I covered the scripting process for the ambient lines in the dialogue system. This time, I'll be talking about the contextual dialogue scripts built for the game.
Contextual Dialogue:
With the ambient dialogue system mostly completed, I turned my attention to the main method by which I wanted the NPC personality I had created to interact with the player: context-based voice lines. Since the majority of lines would play based on objects the player picked up in the game world, I decided (for better or worse) to fire the voice lines inside the interaction script for each object.
Notably, this decision was a bit of a double-edged sword in several ways.
Pros:
- Since it used a method of playback fairly similar to the ambient system that came before it, I was able to get basic functionality up and running fairly painlessly.
- Having the script executed per-item allowed for easy troubleshooting (when a problem would emerge with a particular line, it was easy to find the associated item and therefore isolate the problem).
- The actual logic behind the system itself was fairly simple: cast to the game instance where the dialogue is stored, pick a random line from the relevant set, then display the notification and play the sound file in the same method the ambient lines used.
Cons:
- Headaches when it came to overlapping dialogue lines. Since each item's dialogue script ran similarly but entirely separately from both the ambient dialogue and from the script of other objects, a somewhat unwieldy global timer system had to be constructed to make sure that contextual lines would not overlap one another.
- This script needed to be inserted into every item with corresponding dialogue. For the scope of the game (only four objects with recorded voice lines) this was not a major issue, but nevertheless it limited the versatility of the system as a whole.
- The whole script was very node-heavy, resulting in a fairly messy-looking blueprint.
Lessons Learned:
In hindsight, the contextual dialogue script was a slightly clunky but functional system that suffered from poor legibility and limited versatility. That being said, creating the system was a great learning experience for me that taught me several important lessons:
- Building out a more versatile system should take priority over a "quick fix", as the latter can create unforeseen problems later in a project and limit expansion further down the line.
- collapsing several of the messier portions into functions and reordering some of the inputs and outputs results in a much cleaner and elegant-looking script that still is functional when used (pictured below):
Thanks for reading this post! Next post, I'll be covering some of my work with the scripting of endless hallways and impossible spaces! Until next time!


