Learn narrative design for Unreal Engine with Convai. Create compelling AI-driven stories.
Narrative Design can be extended using Unreal Engine Blueprints, allowing you to invoke triggers created in the Narrative Graph, as well as access dynamic variables such as the time of day or relevant information like inventory contents in the game.
This guide shows how to dynamically pass variables to Narrative Design section and triggers, used with Unreal Engine blueprints.
We will create a simple scenario where the character welcomes the player and asks them about their evening or morning based on the player's time of day.
In the playground, enable Narrative Design on your character and change the starting section name to Welcome
.
Add the following to the Objective field of the Welcome section:
The time of day currently is {TimeOfDay}. Welcome the player and ask him how his {TimeOfDay} is going.
Notice that by adding any string between curly brackets it becomes a variable, and what we did here is adding the time of day as a variable, then from Unreal we can pass either the word "Morning" or "Evening" and the character will respond accordingly.
Back in Unreal, open the character's blueprint.
Set the Narrative Template Keys
variable with a map containing the same variable name TimeOfDay
and for demonstration purposes we will hard code the value to "Morning".
Start the play mode and try it out.
Feel free to try other scenarios and settings to align better with your usecase.
You can use the narrative design keys feature in both sections and triggers.
Make sure the variable names are between curly brackets and has no spaces in between.
You can dynamically set, change or clear the narrative keys in Unreal blueprints.
Master narrative design with Convai's character creator tool. Create engaging AI-driven stories.
Narrative Design enables game developers to outline high-level objectives for NPCs, thereby guiding the narrative flow without constraining it to traditionally rigid dialogue trees. This approach allows for similar behaviour as a state machine but with support for scripted as well as dynamic responses as the NPC progresses through the decision making process from interactions with the player or via triggers from the game state. You can read more about the considerations behind Narrative Design here.
Here is a helpful series of videos outlining how to create a Narrative Design Graph in the Convai Playground, as well as the demo use case we created with a Tour Guide that shows the steps involved in creating your own Narrative Design solution and implementation.
You can find this tool under the "Narrative Design" tab on the Convai Playground. There are three fundamental elements to the graph, Sections, Triggers and Decisions.
Sections consist of two components Objectives and Decisions; and each Section also has a unique ID for ease of reference and tracking.
This defines the overarching goal that the character aims to fulfill. For example, the initial objective for a museum tour guide NPC, is to extend a warm welcome and inquire whether the player is interested in taking a guided tour.
As the conversation unfolds, it becomes essential to adapt to the player's preferences and responses, adjusting the NPC's objectives accordingly. Decisions are critical in this context. Taking the tour guide example further, when the NPC poses the question about taking a tour, the player's affirmative or negative response will lead the NPC to pursue a different objective, tailored to the player's choice. Decisions lead to new sections and allow for the storyline or experience to progress.
You can have a variety of decisions that result from the same Section, each with their own corresponding connection and new objective.
These special character can be utilized in the nodes to trigger specific outcomes.
There are three types of triggers currently: Spatial, Time-Based, and Event-Based. These are essential mechanisms that enable NPCs to discern when certain conditions have been met or events have occurred before proceeding to the next Section. Each trigger has a unique ID for referencing and tracking.
Spatial triggers are activated when characters or players are in the correct location in the experience. For example, standing in front of an information booth could be the Spatial trigger for the NPC to ask the player if they require assistance.
These triggers would occur after a set amount of time has elapsed. For example, if the player has not said anything or responded after a certain number of seconds, the character could repeat the question or inquire what was the delay. Adding more dimensions and natural engagement to the experience.
Event-based triggers correspond to events that occur in the experience or game engine that you would want the characters to respond to. For example, if there was an explosion event in the game, you could have that trigger responses and new Sections from the characters within the range of the explosion event.
This document explains how to extend Narrative Design Triggers with Unreal Engine.
Before proceeding with this section, it is advisable to familiarize yourself with the Narrative Design system, as elucidated in this tutorial.
Develop the logical flow for your specific use case. In this instance, we have created a simple museum tour guide scenario.
Once the logic is decided we can move to Unreal Engine. (In this guide we will use the same setup described in this guide)
Our goal is to invoke the trigger Start Tour
in the narrative Design graph, using the Invoke Narrative Design Trigger
.
The Trigger Name
in the function should be the same as the Trigger
name on the graph.
The above example showcased only one Trigger. The use of more than one Trigger is also possible based on execution logic.
Special Characters | Example | Use |
---|---|---|
<speak>
<speak> I'll say this exact line! </speak>
Characters will respond with exactly the phrase used after <speak> in the node when activated, until the closing </speak> tag.
*
Forces transition to the next node