This guide shows how to dynamically pass variables to the Narrative Design section and triggers.
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.
Activate the Narrative Design for your character in the Playground. Then, create a new Section.
In the Objective section of the new Section, add the following text:
The time of day currently is {TimeOfDay}. Welcome the player and ask him how his {TimeOfDay} is going.
Notice that any string placed between curly brackets becomes a variable. In this case, we are adding the time of day as a variable. From Unity, we can pass either the word "Morning" or "Evening," and the character will respond accordingly.
Now, let’s back to Unity and make the necessary adjustments. Click on your NPC.
Click the Add Component button and add the Narrative Design Key Controller Component.
In the Name field, enter TimeOfDay. In the Value field, specify the corresponding value for that variable, which could be Morning, Evening, or anything else you choose.
That’s it! Now let’s test it out.
Follow this guide to incorporate Narrative Design into your Convai-powered characters. Follow this step-by-step tutorial, open your project, and let's begin!
For this demo, we are using Seraphine Whisperwind
, you can select whatever character you want to enable Narrative Design.
Select the Narrative Design option from the side panel and create your narrative design
For more information how to create narrative design in the Convai Playground please refer to the following YouTube video series
For this sample we have created the following Narrative design
You are all set to bring your character from Convai Playground to Unity, let's hope over to Unity to continue the guide
Narrative Design Manager
in the search box and select itAfter adding the Narrative Design Component, you will be able to be the following component
This component system assumes that API key is setup correctly, so ensure that API key is setup correctly otherwise an error will be thrown.
After adding, component will retrieve the sections for the character ID taken from the ConvaiNPC, please wait for some time depending upon your network speed
The following section events are for character used in demo, and you will see section events corresponding to your character in which Narrative Design is enabled.
Expanding the section event, you will see two unity events you can subscribe to, one is triggered when section starts, and another one is triggered when section ends
Section triggers are a way to directly invoke a section in narrative design and can be used to jump to a different section in your narrative design
Make sure that game object you have decided to be a trigger have a collider attach to it
Now you can select from the "Trigger" dropdown which trigger should be invoked when player enters this trigger box.
We have added a way for you to manually invoke this trigger also, you can use InvokeSelectedTrigger
function to invoke the trigger from any where
You can use this code block as a reference to invoke the trigger from anywhere