Adding Narrative Design to your Character

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!

Convai Playground

Step 1: Select your Character in which you want to enable Narrative Design

For this demo, we are using Seraphine Whisperwind, you can select whatever character you want to enable Narrative Design.

Screenshot showing selection of character in Convai Playground

Step 2: Open Narrative Design in Convai Playground

Select the Narrative Design option from the side panel and create your narrative design

Screenshot showing Icon of 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

Unity Setup

Step 1: Add the Narrative Design Manager Component

1: Select your Convai Character in the scene and look for ConvaiNPC component in the inspector panel. Click on Add Components button

Screenshot showing location of Add Components button in the Convai NPC inspector panel

2: Select Narrative Design Manager checkbox and then click on Apply Changes button

Screenshot showing selection of Narrative design option in the Add Component Window

Using Unity Inspector

1: Select your Convai Character and find Add Component button in the inspector panel

Screenshot showing location of Add Component button in the inspector panel

2: Search for Narrative Design Manager in the search box and select it

Screenshot showing which component to select from the search results

Step 2: Setup the Narrative Design Component

After 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.

Screenshot showing a sample Narrative Design component

Getting to know the Narrative Design Component

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

Screenshot showing various unity events user can subscribe to

Getting to know about Section Triggers

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

Step 1: Select the game object you want to make a trigger, in this example we have selected a simple cube, but it's up to your imagination.

Make sure that game object you have decided to be a trigger have a collider attach to it

Screenshot showing a game object with a collider selected

Step 2: Add Narrative design Trigger from Add Component menu by searching for it

Screenshot showing selection of Narrative Design Trigger

Step 3: Make the collider a trigger.

Screenshot showing Box Collider becoming a trigger box

Step 4: Assign your Convai NPC to Convai NPC field

Screenshot showing assigning of Convai NPC to trigger component

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

Screenshot showing ability to select your desired trigger

Invoke Trigger from any script

You can use this code block as a reference to invoke the trigger from anywhere

if(convaiNPC.TryGetComponent(out NarrativeDesignTrigger narrativeDesignTrigger))
{
    //Optional message parameter if you want to send some message while invoking
    //the trigger 
    string message = "Player has collected enough resources";
    narrativeDesignTrigger.InvokeSelectedTrigger(message);
}

Last updated