Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Integrate advanced conversational AI to create intelligent, interactive NPCs for your games.
Convai's Unity SDK provides you with all the tools you need to integrate conversational AI into your Unity projects. Convai offers specialized NLP-based services to build intelligent NPCs for your games and virtual worlds. Our platform is designed to seamlessly integrate with your game development workflow, enhancing the interactivity and depth of your virtual environments.
Conversational AI: Leverage advanced NLP capabilities to create NPCs that can understand and respond to player input in natural, engaging ways.
Intelligent NPCs: Build characters with dynamic dialogue and behaviors that adapt to player actions and the game world.
Easy Integration: Our SDK is designed for quick and simple integration with your Unity projects, allowing you to focus on creating compelling gameplay experiences.
Cross-Engine Support: In addition to Unity, Convai supports other popular game engines, ensuring broad compatibility and flexibility for your development needs.
This is the Core version of the plugin. It has a sample scene for anyone to get started. This version of the plugin only contains the basic Convai scripts and Character Downloader.
Visit convai.com for more information and support.
Follow these instructions to setup the Unity Plugin into your project.
The file structure belongs to the Core version of the plugin downloaded from the documentation.
In the Menu Bar, go the Convai > API Key Setup.
Go to convai.com, and sign in to your Convai account. Signing in will redirect you to the Dashboard. From the dashboard, grab your API key.
Enter the API Key and click begin.
This will create an APIKey asset in the resources folder. This contains your API Key.
Open the demo scene by going to Convai > Demo > Scenes > Full Features
Click the Convai NPC Amelia and add the Character ID (or you can keep the default character ID). You can get the character ID for your custom character from this page Create Character. Now you can converse with the character. The script is set up so that you have to go near the character for them to hear you.
Now you can test out the Convai Demo Scene and talk to the character present there. Her name is Amelia and she loves hiking!
You can open the Convai NPC Script to replicate or build on the script to create new NPCs.
Try to extend the ConvaiNPC.cs script instead of directly modifying it to maintain compatibility with other scripts
Download Convai tools for Unity. Access the latest plugins and updates for AI integration.
Unity Verified Solution
This is the Long-Term Support version of our core version. It contains all the necessary tools for adding conversational AI to your characters.
WebGL
This plugin version should be used if you need to build for WebGL. Please ensure that Git is installed on your computer prior to proceeding.
There are some limitations for WebGL version of the plugin, to learn about it, please go to Limitations of WebGL Plugin
Unity Plugin Utilities - Enhance development with Convai's tools and resources.
Settings Panel - Customize settings using Convai's Unity plugin utilities.
Settings Panel consists of two main sections.
Audio Settings
Interface Settings
The Microphone Settings section is primarily for troubleshooting and testing the microphone when using the Convai plugin.
In the Input section, you can view the microphones connected to your computer and select the desired one.
In the Test Input field, you can record your voice using the selected microphone in the Input section. After clicking Stop, you can listen to the recorded voice and observe the sound levels.
The first setting that greets us here is the Appearance setting.
In the Appearance section, you can switch between Transcript UI designs.
There are three Transcript UI options:
ChatBox
QuestionAnswer
Subtitle
The second section in Interface Settings is the Display Name section. This section allows you to change how the user's name appears in the Transcript UI.
The last section in Interface Settings is the Notifications Checkmark.
Convai sometimes displays notifications on the screen to inform the user. If you want to disable these notifications, you can click the checkbox here. ( If the box is green, it's active. If empty, it's inactive )
For more information about notifications, you can refer to this link.
Convai offers comprehensive transcript and voice support for a wide range of languages. To facilitate seamless integration, our Unity plugin comes with a custom TextMeshPro (TMP) package, which includes essential fonts and required settings for major languages.
This requires TMP Essentials pre-installed, which can be done through the TextMeshPro option in the Window tab or through a prompt on starting the project.
To implement these language-specific features in your project:
Navigate to the Convai Setup Window within Unity.
Locate the Package Management section.
Click on the "Convai Custom TMP Package" button.
Once installed, just import the character for which you require the language support, talk with it and the font will automatically render in the transcript.
For now, we provide fonts for these languages:
Arabic
Japanese
Korean
Chinese
We also provide support for Right-to-Left languages, like Urdu, Persian and Arabic through our Chat UIs. So, for example, if you talk with an Arabic character or if the character's name is in Arabic, the text will automatically enable the RTL feature provided by unity to reflect proper transcripts.
Resolve facial blendshape issues in Unity animations with Convai. Improve character realism.
If the Lip-sync from characters are either not visible or are very faint, if could be a result of character's animations overriding the blendshape changes made by the script. We recommend deleting the relevant components in the animation dopesheet.
Resolve microphone permission issues in Unity with Convai. Ensure smooth voice interactions.
If you see the microphone indicator turning on in the top left corner but no user transcript in the chat UI and the character's response doesn't seem coherent to what you said, then it is likely that the game or Unity is not accessing the correct microphone or does not have sufficient microphone privilege. To fix this, please follow along.
You can point at Interactable Objects and Characters and ask your characters about them.
To enable this, simply drag and drop the Convai Crosshair Canvas
prefab into the scene.
Check Convai plugin compatibility with Unity. Ensure smooth integration with your development tools.
The minimum supported Unity version is 2022.3.x. Earlier versions may not be compatible.
Windows
MONO
.NET Standard 2.1 or .NET 4.x+
MacOS
MONO
.NET Standard 2.1 or .NET 4.x+
Android
IL2CPP
.NET 4.x+
iOS
IL2CPP
.NET 4.x+
MONO
.NET Standard 2.1 or .NET 4.x+
IL2CPP
.NET 4.x+
2022.3 or Higher
.NET Standard 2.1 or .NET Framework
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.
Fix missing Newtonsoft JSON issues in Unity with Convai. Resolve integration problems efficiently.
Our plugin has various scripts and dependencies that use Newtonsoft Json. If Newtonsoft Json is missing from the plugin, it could lead to a large number of errors as shown below:
Ensure that NewtonSoft.Json is present in your packages. Go to your project folder.
Then navigate to Packages folder. In the Packages folder. Click on manifest.json. A json file containing the project dependacies should open up.
Add the Newtonsoft Json Package on top.
The final manifest.json should look like this.
Input Management - Efficiently handle input for Convai's Unity plugin integration.
Make sure that Active Input Handling in
"Project Settings > Player" is set to Both or Input System Package (New).
Our recommendation is Both. This way, you can use both the new and old input systems. Using the old input system can be faster when creating inputs for testing purposes.
Double click on the "Controls" asset in your project tab.
You can setup multiple control schemes for different devices here, currently we have it for PC (Keyboard & Mouse) and Gamepad. For mobile, we have provided joystick and buttons, which are mapped to Gamepad controls for functionality, but you can directly add touchscreen and use its different features to trigger an Input Action. You can also add your own control scheme if you want support for a different device by clicking on "Add Control Scheme".
Find the Input Action you want to change in the above window. If you want to add a new Input Action, refer to the other section in documentation. In this case, we selected "Talk Key Action" to change the talk button. Click on "T [Keyboard]". In the Binding Properties window, click on the " T [Keyboard] " button in the Path field.
Press the " Listen " button in the top left of the opened window. If you prefer, you can choose your desired input from the categories below.
Press the key you want to assign and it will be reflected in the control asset.
First, go to the controls asset mentioned above and use the add button to create an input action. For this example, we will call it interact and provide it the binding with [E] button.
Then, click on the <No Binding> item to setup binding for this action. As before, you can use the listen button (has a UI bug for Windows but works) or you can select the key from dropdown. After selecting the binding (we will select [E] key for this), don't forget to press on the Save Asset option on the top menu.
You will now get an error saying ConvaiInputManager does not implement OnInteract. We need to implement this. Open the " ConvaiInputManager.cs " script to do so. ( " Convai / Scripts / Runtime / Core / ConvaiInputManager.cs " )
Your IDE might suggest you to implement missing members. If it doesn't we can manually write the OnInteract function like in the last figure shown. You receive a callback context which shows which frame input started, performed or got cancelled which you can use for different purposes. And that's it the error should be gone and you are good to go!
This Unity tutorial demonstrates how to implement NPC-to-NPC conversations in 3D virtual environments using Convai's NPC2NPC feature. This functionality enables two NPCs to engage in dynamic, low-latency dialogues on predetermined topics, while allowing players or other game entities to interrupt and interact with them. Thus, this feature can create more engaging and interactive game worlds with use cases like storytelling, tutorial sequences or quest initiation
Check out this demo and tutorial on how to build this in Unity. We are also releasing the sample project source code along with the tutorial to get you started.
Download the free Sample project files:
Unity Asset Store plugin link:
Character Details
Name: Christina Smith ID: 64247ac6-74f8-11ef-be3e-42010a7be011
Name: Kevin Shaw ID: 7ffaee42-74f8-11ef-8980-42010a7be011
NPC2NPC Walkthrough:
Unity Factory Scene HDRP:
Sign up at Convai to get started. For any questions or bug reports, please visit the Convai Developer Forum where our community and support team will be happy to assist you.
Follow these instructions to set up your imported character with Custom Model with Convai.
To import your custom characters into your Convai-powered Unity project, you will first need to bring your model into your project. The model needs at least two animations: one for talking and one for Idle.
When you want to set up your custom character with Convai, you will need your character model and two animations: Idle and Talking.
Create an animator controller with the two animations that looks like this. You should also add a 'Talk' Boolean to ensure that you can trigger the animation. Here is a YouTube tutorial on how to set up an animator controller. This is the bare minimum animator setup that you need to do.
Select your character from the Hierarchy and Add Animator Component
Convai Plugin ships with two pre-made animation controller, you can choose these controllers or can assign your custom controller, whatever fits your need. For this demo we are going with Feminine NPC Animator
With your custom character selected, add a Collision shape of your choice, for this demo we are going with a Capsule Collider
We will make this Collider a trigger, for this we will enable the Is Trigger
option in the inspector panel
We will adjust the Center, Radius and Height of the collider such that it fits our character
With your Custom Character Selection add ConvaiNPC component. By doing so, your Game objectgame should look like this:
We assume that nothing other than pre-instructed components were added by you; your Game Object component list may be different
Copy your character's ID and name from Convai Playground and paste them here.
Now your Custom Character is all set to work with Convai Plugin.
This guide will help you make a scene in unity with Convai Essentials already present in it. It will help you to get started with our plugin very fast.
You can open the new scene window by two ways, first by pressing Ctrl + N
for windows or CMD + N
for Mac on your keyboard, second way is to navigate to File -> New Scene
There will be many scene templates depending upon your project, but in this guide, we are interested in Convai Scene Template so select that and click on Create button.
You can now save the newly created scene in the project at your desired location by either pressing Ctrl + S
on Windows or CMD + S
on Mac. Another method is to navigate to File -> Save Scene
This is open the Save Scene Window, choose your desired location, for this demo we will save it inside Demo folder, but you can save it anywhere in the assets directory.
Give your scene a name and then click on Save Scene button
Now you can import your Convai Character or your Custom Characters by following our complete guide on it
Fix jaw bone issues in Unity avatars with Convai. Ensure smooth lip sync and animations.
If the Lip Sync does not seem to cause any facial animations, even after removing all blendshapes from animations, then the following steps should help resolve the issue.
This is a known issue in Reallusion CC4 characters.
Select the Character and head to the Animator component.
Click the Avatar Field once to select the character's avatar in the Project window.
Select the Avatar and click Configure Avatar.
Select the Head option in the Mapping tab.
Select the Jaw Mapping and set it to None.
Finally scroll down and click Apply.
This will free the avatar's jaw mapping and allow the script to manipulate the Jaw bones.
Follow these instructions to bring a character from the Convai Playground into your Unity Project.
This is how you can import characters from the Convai Playground into your Unity Project.
In the Menu Bar, go the Convai > Character Importer.
Enter the Character ID and click Import.
If you are unsure how to get the character ID, click the "How do I create a character?".
You can get the character ID from the Character Description.
The downloading will take a while. On successful download, you will see the character in the scene with the same GameObject as the character ID.
This character will automatically be set up with the basic Convai Setup including the ConvaiNPC Script and Out-Of-Box Animations.
If you are facing issues with the animations in your imported character, make sure to change the animation type of Ellen@IdleNew
and Ellen@TalkingNew
Animations in the Assets/Convai/Animations
folder to Humanoid
.
Now you are ready to set up the character with transcriptions.
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
Notification System - Implement notifications with Convai Unity plugin utilities.
The Convai plugin comes with default notifications, totaling four. Here they are:
Appears when you press the talk button but there is no active NPC nearby.
Appears if you release the talk button in less than 0.5 seconds.
Appears when the recorded audio input level is below the threshold.
Appears when there is no internet connection upon launching the application.
Adding your custom notification is straightforward.
Let's go through the steps to add a " CharacterStartedListening" notification as an example.
Open the script "Convai/Scripts/Notification System/Notification Type.cs." This script stores Notification Types as enums. Give a name to your desired Notification type and add it here.
Right-click on "Convai / Scripts / Notification System / Scriptable Objects" and select "Create > Convai > Notification System > Notification" then create a "Notification Scriptable Object".
Name the created Notification Scriptable Object. Click on it, and fill in the fields in the Inspector as desired.
Add the created Notification Scriptable Object to "Convai/Scripts/Notification System/Scriptable Objects" under "Convai Default Notification Group" (details of Notification Group here****).
Your Notification is now ready. The last step is to call this Notification from where you need it. For example, if you created the " CharacterStartedTalking " Notification, find the location where your character listens and write the code.
Replace the parameter with the NotificationType you created. (For our example, NotificationType.CharacterStartedListening)
Ensure that the Convai Notification System is present in your scene. (accessible from "Convai/Prefabs/ Notification System")
All steps are complete, and you're ready to test!🙂✅
This Scriptable Object stores information about a Notification
Notification Type
Notification Icon
Notification Title
Notification Message
To create a new Notification Scriptable Object, right-click anywhere in the Project Window and select "Create > Convai > Notification System > Notification"
This Scriptable Object stores Notification Scriptable Objects as groups. When a Notification is requested, it searches for the Notification using the specified Notification Group in the Convai Notification System prefab's Notification System Handler script.
You can create different Notification groups based on your needs. Note: If your referenced Notification Group does not have the Notification you want, that Notification won't be called.
The Convai Default Notification Group has four Notifications, but you can add more or create a new group with additional notifications.
Learn to add lip sync to your Unity characters using Convai. Improve realism and interactivity.
Convai sends Visemes or Blend Shape Frame from back-end depending upon the face model the developer chooses to use and when returned Convai SDK out of the box extracts and parses it and provides it to the Convai LipSync Component
, after which the component relies on the SkinMeshRenderer
's Blendshape Effectors
and Bone Effectors
to give Convai powered NPC's realistic lipsync.
This is where the developer will tell the Convai SDK, which index of Blendshape Array will be effector how much from which value. To better explain its working let's understand it with a diagram.
Here, it is saying that whatever value is coming from the server will affect Blendshape at the 116th index by 0.2 multipliers and Blendshape at the 114th index by 0.5 multipliers. The engine representation of this would look something like this.
So, you can make your own Effector list or use one of the many that we ship in the SDK.
How to Create your own Viseme Effector List
Right click inside project panel and head over to Create > Convai > Expression > Viseme Skin Effector
which will create a Viseme Effector List Scriptable Object and now you can define your own values.
This is where developer will tell the Convai SDK, how much each value coming from the server will affect the rotation of the bone. To better explain its working let's understand it with a diagram.
Here, bone's rotation will be affected by the values coming from the server multiplied by the values in effects. For example, for TH the value will affect the bone's rotation by a 0.2 multiplier and etc. The engine representation of this would look something like this.
So, you can make your own Bone Effector list or use one of the many that we ship in the SDK.
We use this formula to calculate the rotation
How to Create Your Own Viseme Bone Effector List
Right click inside the project panel and head over to Create > Convai > Expression > Viseme Bone Effector
which will create a Viseme Bone Effector List Scriptable Object and now you can define your own values.
When you attach this component to your Convai Character, you will see something like this.
Let's learn what these learns are
Facial Expression Data
Head | Teeth | Tongue
Renderer: Skin Mesh Renderer which corresponds to that specified part of the body
Viseme Effectors List: How the SkinMeshRenderer's Blendshape will be affected by values coming from server.
Jaw | Tongue Bone Effector
How much of Bone's rotation will be affected by values coming from server?
Jaw | Tongue Bone
Reference to the bone which controls jaw and tongue respectively
Weight Blending Power
Percentage to interpolate between two frames in late update.
Character Emotions
Learn More about Character Emotions here Character Emotion
Now you can configure the Component according to your custom configuration or use one of the many Presets Convai ships with the SDK
Now your lipsync component would be ready to use in your application.
Follow these instructions to enable actions for your Convai-powered characters.
Select the Convai NPC character from the hierarchy.
Scroll down to the ConvaiNPC script attached to your character.
Click the "Add Component" button.
Use the checkbox to add the action script to the NPC Actions.
Click "Apply Changes" to confirm.
Convai offers predefined actions for a quick start.
Click the "+" button to add a new action.
From the dropdown menu, select "Move To."
Enter the action name as "Move To" (the name doesn't have to match the action choice name).
Leave the Animation Name field empty for now.
Repeat these steps to add more actions like "Pickup" and "Drop" etc.
Add any object into the scene—a sphere, a cube, a rock, etc.—that can be interacted with
Resize and place the object in your scene.
Create an empty GameObject and name it "Convai Interactables."
Attach the Convai Interactables Data script to this GameObject.
Add characters and objects to the script by clicking the "+" button and attaching the corresponding GameObjects.
Add the "There" object in Objects list, so that we can use the Dynamic Move Target indicator.
To ensure your NPCs can navigate the scene:
Bake a NavMesh for your scene if you haven't already:
Go to Window > AI > Navigation.
In the Navigation window, under the Bake tab, adjust the settings as needed.
Click "Bake" to generate the NavMesh.
Ensure that the NPC character has a NavMeshAgent component:
If not already attached, click "Add Component" and search for NavMeshAgent.
Adjust the Agent Radius, Speed, and other parameters according to your NPC's requirements.
To visually indicate where your NPC will move:
Create a new empty GameObject in the scene and name it accordingly or use the pre-made prefab named Dynamic Move Target Indicator.
Link this Move Target Indicator to your NPC's action script so it updates dynamically when you point the cursor to the ground and ask the NPC to move to "There".
Click "Play" to start the scene.
Ask the NPC, "Bring me the Box."
If setup properly, the NPC should walk upto the box and bring it to you
This feature is currently experimental and can misbehave. Feel free to try it out and leave us any feedback.
Make your NPC perform custom actions like dancing.
Locate the dance animation file within our plugin.
Incorporate this animation into your NPC's actions.
Open the Animator Controller from the Inspector window.
Drag and drop the dance animation onto the controller, creating a new node named "Dancing."
Go to the Action Handler Script attached to your Convai NPC.
Add a new action named "Dancing."
In the Animation Name field, enter "Dancing" (it must exactly match the Animator Controller node name).
Leave the enum as "None."
Click "Play" to start the scene.
Instruct the NPC, "Show me a dance move," and the NPC should start dancing.
Adding advanced custom actions, such as a throw action, to your NPC.
Import it into Unity.
Add the "Throw" enum to the script.
In the "Do Action" function, add a switch case for the throw action.
Define the "Throw()" function.
Add a new action named "Throw" and select the "Throw" enum.
Leave the animation name field empty.
Add any rock prefab into the scene.
Add the rock to the Convai Interactable Data script.
Add a stage/new location in the ground of the scene.
Add that new location game object in the Convai Interactable Data.
Click "Play" to start the scene.
Instruct the NPC, "Pick up the rock and throw it from the stage."
If everything is set up properly, the NPC should pick up the rock and throw it from the stage.
That’s it! Now let’s test it out.
Add the and setup to you NPC.
Grab a or anywhere you like.
Drag and drop the throw animation onto the controller, creating a new node named "Throwing." (Follow steps in )
With Convai's Unity SDK, you can build your favorite application for several platforms, including Windows, MacOS and Android. Currently, we also support these platforms:
Review the prerequisites for integrating Convai with Unity. Ensure seamless setup and functionality.
The Convai Unity SDK supports a minimum of Unity 2022.3.x or later.
You should have Git installed locally on your system.
Before integrating the Convai SDK, you should be comfortable with the following:
Importing Packages: Know how to import external packages into a Unity project.
Unity Editor: Be proficient in navigating the Unity Editor interface.
Animations: Understand how to add and handle animations for assets.
Programming in C#: Have a basic experience programming Unity scripts in C#.
Script Integration: Be capable of adding scripts to a game object.
Building and Deployment: Know how to build and deploy an application to your chosen platform.
Having these skills will ensure a smooth integration and optimal use of the Convai Unity SDK in your projects.
Understand the limitations of the WebGL plugin for Unity with Convai. Optimize your development.
iOS browsers impose strict limitations on the size of WebGL builds. These constraints are primarily due to:
Memory Limits: iOS devices have limited available memory for web applications, which can affect the performance and feasibility of running large WebGL builds.
Browser Storage Quotas: Safari and other iOS browsers restrict the amount of data that can be stored locally. This includes caching and Indexed DB, which are often used to store assets for WebGL builds.
Maximum Downloadable Asset Size: iOS browsers may restrict the size of individual downloadable assets. Large assets might fail to load, causing the application to break.
Total Build Size: The total size of all assets combined should ideally be kept under 50-100 MB for smooth performance. Exceeding this limit can lead to crashes or extremely slow loading times.
Memory Usage: iOS devices typically have less RAM available compared to desktop environments. High memory usage by WebGL builds can result in frequent browser crashes.
Safari: The default browser on iOS, Safari, is generally the best option for WebGL builds, but it still has significant limitations compared to other desktop browsers.
Session ID Management - Manage unique session IDs for Convai Unity integration.
In a typical application integrating with the Convai API, maintaining a consistent session ID across different sessions is crucial for providing a seamless user experience. This documentation outlines the best practices for storing and retrieving session IDs using Unity's PlayerPrefs
, including detailed steps and example scripts.
A session ID uniquely identifies a session between the client and the Convai server. Storing the session ID locally ensures that the same session ID is used across different sessions, which helps in maintaining context and continuity in interactions.
When initializing a session, if a session ID is not available locally, it should be fetched from the server and then stored locally for future use. Here's how you can achieve this:
Fetch and Store Session ID: When initializing a session, check if a session ID is stored locally. If not, fetch a new session ID from the server and store it using PlayerPrefs
.
When initializing your application, retrieve the stored session ID to ensure continuity in user interactions.
The following example class demonstrates how to manage session IDs using PlayerPrefs
in a Unity project:
Initialize Session: Call InitializeSessionIDAsync
to check if a session ID is stored. If not, fetch and store it.
Store Session ID: Use PlayerPrefs.SetString(characterID, sessionID)
to store the session ID locally.
Retrieve Session ID: Use PlayerPrefs.GetString(characterID, string.Empty)
to retrieve the stored session ID.
Use Session ID: Pass the session ID to your Convai API calls to maintain session continuity.
Error Handling: Ensure proper error handling when fetching and storing session IDs.
Security: Consider encrypting sensitive information stored in PlayerPrefs
.
Performance: Use asynchronous methods to avoid blocking the main thread when fetching session IDs.
Convai Unity Plugin Changelogs - Stay updated with the latest changes.
Released: October 31, 2024
Implemented Dynamic Config Feature:
This feature allows you to dynamically pass variables to NPCs. For example, you can update NPCs with the player’s current health, inventory items, or information about the world, enhancing interactivity and immersion.
Implemented Narrative Design Keys:
This feature enables dynamic variable passing within the Narrative Design section and triggers. For instance, you can use placeholders like {TimeOfDay} to create personalized dialogues, such as "Welcome, player! How is your {TimeOfDay} going?"
Added MR Demo Scene
Added MR Automatic Installation and Manual Installation
Added Convai XR Package (compatibility with Meta SDK and other XR SDKs provided)
Added Long Term Memory API(s) to View and Delete Speaker ID(s)
Improved VR Manual Installation
Improved Custom Package Installation
Minor Bug Fixes
Released: September 16, 2024
Minor Bug Fixes
Released: September 12, 2024
Fixed NPC2NPC response delay
Released: Aug 28, 2024
New Convai Setup Editor Window
Long term memory (beta) integration in Unity SDK
ChatBox UI revamp with RTL support
Input system revamp and Mobile UI improvements
UI Improvements
Revamped ChatBox UI
Improved mobile UI
Implemented chat disabling feature
Added usage limit exceeded notification
Dialog box added for no API Key scenario
API and Backend
Refactored ProcessUserQuery for better transcript handling
Implemented fuzzy matching for Action System
Ready Player Me and CC_Tools automatic import process
Character and Animation
Updated Character Importer Pipeline
Added OVR effectors for RPM characters
Fixed animators for all characters
Provided Weight Multiplier for LipSync user preference
RPM Characters will have Lipsync added when imported
Bug Fixes
Fixed character resuming dialogue after toggle
Fixed section deletion issue in NarrativeDesignManager
Fixed layer issues
Optimised Convai LipSync
Developer Tools and Workflow
Improved Convai Logger System
Updated namespace and formatting for all editor scripts
Removed CC Tools Folder and other temporary/junk files
Added "Update Triggers" button to NarrativeDesignTrigger inspector
Implemented approximate string matching for actions system
Miscellaneous
Added PlayerDataHandler and PlayerDataSO
Updated NPC positions and topics in demo scenes
Fixed Convai logo in Convai Setup window
Released: Jun 21, 2024
Fix macOS TMP UGUI render issue in demo scene
Prefab missing animator
Updated ActiveNPC layer check logic
Released: Jun 13, 2024
Implemented NPC2NPC conversation flow system.
Added handling for conversation interruptions and restarts.
Enhanced conversation history tracking and flow management.
Added Narrative Design-related files and trigger narrative section function.
Refactored Narrative Design API, created new behavior trees for movement and added section change events.
Folder Restructuring
Complete folder and scripts folder restructure
Gender-Based Animator: Added gender-based Animator controller
Feedback System
Implemented a feedback system with thumb icons and animations
Updated Transcript UI Prefabs with feedback buttons
Convai Custom Packages: Updated Convai Custom Package Installer and added iOS DLL Downloader
Scene Perception: Added feature to allow players to point at game objects and talk about them
Texture and Material Compression
Compressed Amelia and other images (POT and Crunch)
Updated image names and removed unused image assets
UI Updates
Updated UI prefabs, including Transcript UI, Mobile UI, and Mobile QA UI
Transcript UIs and text updated
Updated logos and logo paths
System Improvements
Refactored Lipsync system with added teeth support and implemented facial expression proto files
Updated ConvaiURPConverterPackage, burst and TMPro packages; Convai Custom Package Installer/Exporter
Updated NavMesh and NPC2NPC character rotation
Added new demo scene and RPM characters
Updated various demo scenes for consistency
Microphone Manager: Updated Microphone Manager to a singleton class
API Key Access: Simplified API Key access
Convai Scene Template: Created new scene template and dynamic input system assigner
Demo Scenes
Added NPC2NPC demo scene
Added Narrative Design demo scene
Added new demo scene with all features encompassed
"Convai Essentials" prefab for desktop and mobile
Lipsync Overhaul
Overhauled lipsync system, added AR-Kit and Reallusion character support
Updated version and added various improvements to frame processing
Input System
Added new input system pragma checks and Convai Character Layer
Simplified Input Manager and ensured future-proofing
Transcript UI Bug Fixes: Fixed bugs and improved system for Transcript UI character list
Microphone Permission: Fixed Android and iOS microphone permission issues
VR Support: Implement Virtual Reality features to create a fully immersive experience with the press of a button.
AR Support: Integrate Augmented Reality capabilities, allowing characters and environments to interact with you in the real world with the press of a button.
Settings Panel: Introduce a comprehensive settings panel that allows users to customize their experience.
Microphone Test System: Incorporate a microphone testing feature to ensure optimal audio input quality.
Notification System: Implement a robust notification system to inform users of in-game events - specifically microphone-based issues.
Input Manager: Develop a custom input management system that supports various input devices such as keyboards, gamepads, and touchscreens using Unity's new Input System.
Fixed: Head Tracking Doesn’t Work Without Action Component issue fixed.
Improvement: Added support for a customizable and dynamic Chatbox.
Improvement: Improved Lip-Sync Smoothing and audio-visual synchronization.
Improvement: Implement Action Events and Event Callbacks.
Improvement: Improved Logging System.
Improvement: Added ability to interrupt Character Response with Voice Interruption.
Improvement: Improved mobile platform transcription UI.
Lip-sync: Integrate off-the-shelf Lip-sync for Reallusion and Oculus-based Characters.
Text-in Voice-out: Chat with the character using text.
Character Importer: Import Ready Player Me characters created on the Convai Playground.
Feature Control System: Enable Convai features as needed through the Convai NPC component.
Logging System: Have better control over what Convai information you see on the debug console.
Enhanced player controller: Automatically triggers the characters when you focus on them and then deactivates them when your focus has shifted.
URP Upgrader: Upgrade the Render Pipeline to Universal Render Pipeline with the URP Upgrader package (present in the Convai Folder).
UI Improvements: Improved user experience with automatically fading UI canvas.
Fixed: Unlocking the cursor will still cause the first-person camera to move around.
Fixed: Exiting play mode before the character is done speaking will cause Unity to crash or not complete compilation.
Fixed: Extra space between multiple chunks of text in the UI Text Fields.
Fixed: Actions crashing the Android scene.
Fixed: Empty responses from the server will not crash the game but only throw an error.
Improvement: Smoothened Blinking.
Improvement: Smoothened Gaze-Following-based Neck movement.
Improvement: Plugin structure reorganization.
Troubleshoot common issues with Convai's Unity plugin. Get solutions for seamless AI integration.
A. Please check if there are any errors in the console. Unity needs to be able to compile all the scripts to be able to display any custom editor menu options. Resolving all the console errors will fix this issue.
A. Primarily, two issues cause errors in the console that can stem from the Convai Unity Plugin. You can use the links below to fix them quickly.
A. This may indicate issues with the microphone. Please ensure that the microphone is connected correctly. You also need to ensure that the applications have permission to access the menu.
A. The animation avatar that we are using might be incompatible with the character mesh. Fixing that can solve the issue.
Default Animations Incompatibility
A. If you are using Unity 2021, unexpected prefab variant issues may arise. This is because Unity Mobile Transcript UIs are variants of the main transcript UI prefab. With changes in the Prefab system in Unity 2022, it works correctly in Unity 2022. If you are using Unity 2021, you may encounter issues with prefabs. You can remove the redundant Settings Panel Button to address this problem.
A: The animations that we are using may be modifying facial animations. Editing the animations to remove facial animations should fix any issues related to lipsync.
Animations have Facial Blendshapes
A: The script also needs the avatar to not be mapped to the jaw bone to be manipulate the jaw bones itself.
Jaw Bone in Avatar is not Free
grpc_csharp_ext.bundle
DLL inside the Unity Editor on MacOSA: macOS's strict security measures can block certain external unsigned DLLs. To address this, you can manually allow the DLL in "Security & Privacy" settings, modify Gatekeeper's settings through Terminal, ensure correct file permissions for the DLL, check its settings in Unity, and update the Mac Configuration in Unity's Player Settings
A: The issue is rooted in the grpc_csharp_ext.bundle
used in Unity for networking. This DLL has separate versions optimized for Intel and Apple Silicon architectures. When trying to create a Universal build that serves both, compatibility problems arise, especially on Intel Macs. Presently, the best solution is to use Standalone build settings specific to each architecture.
Building for macOS Universal apps
Follow this Table to navigate to our most common errors.
Enabled Assembly Validation
Unity, by default, checks for exact version numbers for the included assemblies. For our plugin, this is not necessary, since we use the latest libraries.
Missing NewtonSoft Json
Our plugin needs Newtonsoft Json as a dependency. It is often present as part of Unity but occasionally, it can be missing.
Missing Animation Rigging
We use the Animation Rigging package for Eye and Neck tracking. If Unity does not automatically add it, we need to add it manually from the package manager.
Microphone Permission Issues
The microphone icon lights up but there is no user transcript in the chat UI. The character seemingly not replying to what the user is saying.
The plugin requires microphone access which is sometimes not enabled by default.
Default Animations Incompatibility
The default animations that ship with the plugin seems broken. The hands seem to intersect with the body.
The animation avatar is incompatible with the character mesh.
Animations have Facial Blendshapes
The Lip-sync from characters are either not visible or are very faint.
Some types of animations control facial blendshapes. These animations prevent the lip-sync scripts to properly edit the facial blendshapes.
Jaw Bone in Avatar is not Free
The Lip-sync from characters are either not visible or are very faint.
The animation avatar for the character may be using the Jaw Bone. If we set the mapping free to none, the script will be able to manipulate the jaw bone freely.
Mac Security Permission Issue
Security Permission Issues with grpc_csharp_ext.bundle
DLL in Unity on MacOS.
MacOS's security protocols can prevent certain unsigned external DLLs, like grpc_csharp_ext.bundle
, from functioning correctly in Unity.
Microphone Permission Issue with Universal Builds on Intel Macs in Unity
No Microphone access request pops up
Incompatibility between Intel and Apple Silicon versions of grpc_csharp_ext.bundle
when attempting a Universal build.
For any other issues, feel free to contact us on the Convai Developer Forum.
In this guide, we learn about character emotion coming from server
Convai Character emit character emotions when they interact with the player and these emotions help in making the character more human-like, we are starting to implement a system which you as a developer can use to make your game more interactive using the character emotions.
Whenever the character responds to the user, we send back a list of emotions to the SDK, which look something like this
For v0 of this system, we will only be sending the emotions, in future we will apply the facial expressions corresponding to each emotion which will make the character more interactive.
This Unity tutorial shows you how to add a Convai-powered Tour Guide character for your 3D virtual environments. Convai’s Narrative Design Feature lets creators add spatial anchors in the 3D environment which guides the 3D AI character to navigate the world while following step-by-step instructions. The character follows instruction prompts combined with the spatial anchors while conversing with the user in a contextual open-ended manner. This enables a whole set of use cases from onboarding, tour guides, companion characters, tutor characters, and many more. Check out this demo and tutorial on how to build this in Unity. We are also releasing the sample project source code along with the tutorial to get you started.
Download the free Sample project files:
Unity Asset Store plugin link:
Character Details
Name: Christina Smith ID: 84434252-3776-11ef-a746-42010a7be00e
Narrative Design Walkthrough:
Unity Factory Scene HDRP:
Sign up at Convai to get started. For any questions or bug reports, please visit the Convai Developer Forum where our community and support team will be happy to assist you.
MR development with Convai
Setting up Convai for Mixed Reality (MR) is easier than you might think. With just a few clicks, you can get Convai integrated directly into your MR projects.
To give users flexibility and customization options, we offer two installation methods:
Automatic Installation
Manual Installation
The Automatic Installation method is ideal if you’re starting a new project and want to avoid dealing with MR packages or additional setup requirements. This method provides a fully Convai-integrated MR project right from the start, including the Convai MR Demo Scene for quick testing and exploration. This approach is particularly suitable for beginners.
Note: This installation method will modify Unity Project settings. These changes are necessary to ensure compatibility with Convai.
The Manual Installation method is designed for existing MR projects. With this method, you have full control over the setup, as no project settings are modified, no demo scenes are added, and no customizations are applied. Only Convai’s XR Unity Package will be integrated, giving you the freedom to use any MR SDKs without restrictions.
Select one of the two installation methods and click on the corresponding setup section below to follow the instructions.
If you ever get an error that looks like this, disable the Assemble Version Validation in Project Settings
> Player
> Other Settings
.
Ensure that Assembly Validation is disabled in Project Settings
> Player
> Other Settings
.
Restart the Unity project after unchecking the box should fix the issue.
This installation method is ideal for users working with existing projects who wish to customize their setup. It allows for compatibility with various other SDKs, enabling you to integrate Convai seamlessly into your current workflows without limitations on using third-party SDKs.
In the top menu, click on Convai. Then, select Custom Package Installer.
In the Convai Panel that appears, click on Package Management and then select Install VR Package.
A new window will appear prompting you to select your installation type. For this documentation, we will proceed with Manual Installation.
The installation will start. This process will be completed quickly as only the ConvaiXR Package will be installed.
Once installation is complete, the Convai Essentials - XR Prefab will be added to your scene.
This is the only GameObject required for Convai to run in your scene.
The imported files can be found under Assets > Convai > ConvaiXR.
The final step is to import your character into the scene.
If you need guidance on this, please refer to the relevant documentation here.
To activate Convai in your scene, simply add the Convai Essentials - XR Prefab.
There are no limitations on Third-Party SDKs, so you are free to use Convai with any XR SDK of your choice.
Please follow this documentation to interact with Convai's Settings Panel.
This installation method is ideal for users working with existing projects who wish to customize their setup. It allows for compatibility with various other SDKs, enabling you to integrate Convai seamlessly into your current workflows without limitations on using third-party SDKs.
In the top menu, click on Convai. Then, select Custom Package Installer.
In the Convai Panel that appears, click on Package Management and then select Install MR Package.
A new window will appear prompting you to select your installation type. For this documentation, we will proceed with Manual Installation.
The installation will start. This process will be completed quickly as only the ConvaiXR Package will be installed.
Once installation is complete, the Convai Essentials - XR Prefab will be added to your scene.
This is the only GameObject required for Convai to run in your scene.
The imported files can be found under Assets > Convai > ConvaiXR.
The final step is to import your character into the scene.
If you need guidance on this, please refer to the relevant documentation here.
To activate Convai in your scene, simply add the Convai Essentials - XR Prefab.
There are no limitations on Third-Party SDKs, so you are free to use Convai with any XR SDK of your choice.
Please follow this documentation to interact with Convai's Settings Panel.
Interacting with the UI may vary depending on the SDK you are using. For popular frameworks like XR Interaction Toolkit and Meta SDK, you can follow the documentation below. We recommend checking the relevant documentation for other SDKs.
To make the Settings Panel interactable in XR environments, where you can test your microphone at runtime or change the appearance of the Chat UI in Convai, follow these steps:
Right-click on the Convai Settings Panel.
Select Interaction SDK and then click on Add Ray Interaction to Canvas.
If a warning appears in the new window, click the Fix button.
In the Settings section, choose Everything. Then click Create.
To prevent the ISDK_RayInteraction from running while the Settings Panel is closed, drag it onto the Panel GameObject.
Click on the Convai Settings Panel.
In the Inspector, click the Add Component button.
Add the Tracked Device Graphic Raycaster component.
Fix default animation incompatibilities in Unity with Convai. Ensure smooth AI character animations.
If the default animations that ship with the animator look bugged such that the hand seems to intersect with the body, it could indicate an issue with the wrong animation avatar being selected.
You can easily fix that by heading to the character's animator component and assigning the correct animator to the Avatar field.
The correct animation will look something like this. The hands should not intersect the body.
Convai UI Prefabs - Utilize ready-to-use UI elements for Convai integration.
We provide several UI options to display character and user's transcript out of the box that players can use with the Convai Plugin. You can use and customize these prefabs.
The ConvaiNPC and ConvaiGRPCAPI scripts look for GameObjects with Convai Chat UI Handler as a component, and send any transcripts to the script so that it can be displayed on screen.
Prefab Name: Convai Transcript Canvas - Chat
Both the user's and the character's transcripts are displayed one after other in a scrollable chat box.
Prefab Name: Convai Transcript Canvas - Subtitle
The user and character transcripts are displayed in the bottom like subtitles.
Prefab Name: Convai Transcript Canvas - QA
The user's transcript is displayed in the top where as the character's transcript is displayed in the bottom.
Prefab Name: Convai Transcript Canvas - Mobile Subtitle
Identical to #subtitle UI. Includes a button that can be pressed and held for the user to speak. Ideal for portrait orientation of screen.
Prefab Name: Convai Transcript Canvas - Mobile QA
Prefab Name: Convai Transcript Canvas - Mobile Chat
SendCharacterText
A public function that sends a string of text to be displayed as character transcript along with the name of the character who said it.
SendUserText
A public function that sends a string of text to be displayed as user transcript.
All the information that Convai SDK needs from the player to work properly
This is a scriptable object which is made automatically after you hit play in the editor with Convai SDK installed and in a Scene where Convai Base Scene Essentials Prefab is present
Default Player Name
You can provide a default name of your players.
Player Name
Current name of your player, out of the box if you use our settings panel, we keep it updated automatically, if you are using some custom logic, it will be your responsibility to keep it updated, as our transcript UI use this name to show it in UI
Speaker ID
Speaker ID for the player. Please note that Speaker ID is directly linked with your API key, so for each API key there should be a unique speaker ID associated with it. We handle the creation of the Speaker ID when it's not found in the Player Prefs if the Boolean is set to true.
Create Speaker ID If Not Found
This Boolean lets the SDK if it should create a unique Speaker ID for that Player Name if it is not found in the Player Prefs.
It just makes the Player Name and Speaker ID fields empty.
Copies the data into system buffer so you can paste it anywhere for debugging purpose
Load: Loads the Player Name and associated Speaker ID from the player Prefs
Save: Saves the Player Name and associated Speaker ID from the player Prefs
Delete: Deletes the Player Name and associated Speaker ID from the player Prefs
Convai provides a pre-made component which you can add to any GameObject
to make the PlayerDataContainer
work out of the box.
Choose an existing GameObject or create a new GameObject
in the scene and add the ConvaiPlayerDataHandler
component to your chosen GameObject
and it should start working
You can also create the required Scriptable Object by going to Assets > Convai > Resources
and right clicking in the project panel and navigating to Create > Convai > Player Data
and name it ConvaiPlayerDataSO
Make sure you name the created Scriptable Object exactly ConvaiPlayerDataSO
as our system looks for this exact name
When building Unity projects for macOS, developers may encounter issues with microphone permissions, particularly when targeting both Intel and Apple Silicon Macs. This document outlines the problem, symptoms, causes, and solutions to help ensure successful access to the microphone across different Mac architectures.
Some users have reported that while building macOS universal apps, Apple Silicon Macs handle microphone permissions without issue, while Intel Macs may fail to access the microphone due to differences in architecture. This can result in a lack of microphone response, DLL not found Exceptions, error messages, potential application crashes, or no audio input being detected.
The issue stems from the grpc_csharp_ext.bundle
, which is crucial for networking in Unity projects. There are separate versions of this DLL for Intel and Apple Silicon architectures, and they cannot be easily merged or applied universally. The grpc library currently lacks dedicated support for resolving these dll issues in Unity.
For Intel Macs: Use Standalone builds targeted specifically for the Intel architecture to ensure compatibility.
For Apple Silicon Macs: Prefer Standalone builds for the ARM64 framework for optimal performance, although Universal builds are also an option.
After completing a Universal build on an Intel Mac, you must manually update the grpc_csharp_ext.bundle
to ensure proper functionality. Follow these steps:
Locate the .app
file generated by the build process.
Right-click on the .app
file and select "Show Package Contents."
Navigate to the Contents/Plugins
folder within the package.
Replace the contents of this folder with the components from the provided plugin folder (link to plugin folder).
Important: The grpc_csharp_ext.bundle
may not be included correctly in the final build when built from an Intel Mac. Always verify that the Plugins
folder in the build contains the correct DLLs. If there is any confusion or the DLLs are missing, replace or add the contents of the Plugins
folder with the one provided by us.
Building for macOS requires careful consideration of the distinct Intel and Apple Silicon architectures. The current best practice is to use Standalone build settings tailored to the specific architecture of the target Mac. As we progress, we will have a more integrated solution for managing DLLs that will simplify the development process for universal macOS applications.
VR development with Convai
Setting up Convai for Virtual Reality (VR) is easier than you might think. With just a few clicks, you can get Convai integrated directly into your VR projects.
To give users flexibility and customization options, we offer two installation methods:
Automatic Installation
Manual Installation
The Automatic Installation method is ideal if you’re starting a new project and want to avoid dealing with VR packages or additional setup requirements. This method provides a fully Convai-integrated VR project right from the start, including the Convai VR Demo Scene for quick testing and exploration. This approach is particularly suitable for beginners.
Note: This installation method will modify Unity Project settings. These changes are necessary to ensure compatibility with Convai.
The Manual Installation method is designed for existing VR projects. With this method, you have full control over the setup, as no project settings are modified, no demo scenes are added, and no customizations are applied. Only Convai’s XR Unity Package will be integrated, giving you the freedom to use any VR SDKs without restrictions.
Select one of the two installation methods and click on the corresponding setup section below to follow the instructions.
The Automatic Installation method is ideal for users starting new projects who want a straightforward setup. It provides a fully integrated Convai VR project from the beginning, ensuring a smoother development experience.
In the top menu, click on Convai. Then, select Custom Package Installer.
In the Convai Panel that appears, click on Package Management and then select Install VR Package.
A new window will appear prompting you to select your installation type. For this documentation, we will proceed with Automatic Installation.
In the next window, carefully read the setup instructions, warnings, and details of the changes that will be applied.
When ready to proceed, click Yes, proceed.
The installation process will begin, taking approximately 5 minutes. The duration may vary depending on your computer's performance.
Once the installation is complete, it’s time to open the demo scene.
Navigate to Assets > Convai > ConvaiXR > ConvaiVR > Scenes and open Convai Demo - VR.
If you don’t have the TextMeshPro package installed, you’ll need it to display text properly in the demo scene. To install it:
Go to Window > TextMeshPro > Import TMP Essential Resources.
In the Unity Package Import window that appears, click Import.
You can build your project by going to File > Build Settings.
This guide will walk you through setting up the NPC to NPC conversation feature in the Convai SDK.
Go to your Convai NPCs:
Select the NPCs you want to include in the conversation.
Enable Group NPC Controller:
Click on the Group NPC Controller
checkbox in the inspector panel.
Click Apply Changes
to add the group NPC controller script.
Create or Find the Speech Bubble Prefab:
Create a new speech bubble prefab or use the one provided in the Prefabs
folder.
Attach Required Components:
Add the speech bubble prefab and the player transform (optional, defaults to the main camera if not provided).
Set the conversation distance threshold variable (set it to zero to disable this feature, meaning NPC to NPC conversations will always happen regardless of the player’s distance).
Add Relevant Components:
Add components like lip sync, eye and head tracking, character blinking, etc., to the Convai NPC.
Create an NPC To NPC Manager GameObject:
Add an empty GameObject and rename it to NPC to NPC Manager
(optional).
Add the NPC2NPC Conversation Manager Script:
Attach the NPC2NPCConversationManager
script to the GameObject.
Configure the NPC Group List:
In the NPC Group List
, click on the +
icon to add a new list element.
Add the NPCs you want to include in the group conversation.
Set the group discussion topic.
Post configuration of NPCs
Bring the NPCs close together
Play the to make sure everything is working as intended.
By following these steps you can set up and manage NPC to NPC conversations in your Convai-powered application. For further customization and integration, refer to the complete implementation code and adjust it as needed for your specific use case.
The Dynamic Config feature enables you to pass variables to NPCs in real time, allowing them to react dynamically to changes in the game environment. This can include the player’s current health, inventory items, or contextual world information, greatly enhancing interactivity and immersion.
First, Add the Dynamic Info Controller Component to your Convai NPC.
Create a new script or use an existing script to define a variable that will store a reference to the Dynamic Info Controller Component you added to your NPC.
Initialize the Dynamic Info: In the script’s Start method, call the SetDynamicInfo
method on the Dynamic Info Controller reference. This will set the dynamic information that the NPC will use. In this example, we’ll initialize the Player’s health as a dynamic variable.
Updating the Dynamic Info: Whenever you need to update the NPC with new information (such as a change in Player Health), call the SetDynamicInfo
method on the Dynamic Info Controller.
At the start of the game, we set the Player’s health to 100 and send this information to the NPC as the initial value.
Then, when the player takes damage (simulated here by pressing the "K" key), we reduce the Player’s health and update the Dynamic Info in real time so that the NPC remains aware of the Player's current health status.
Below, we provide a sample conversation showcasing how the NPC can react based on the dynamic health information of the Player. By dynamically updating the Player's health, NPCs can deliver responses that feel personalized and relevant to the current gameplay.
Add the Dynamic Info Controller to your NPC. Use SetDynamicInfo
to initialize the dynamic variable at the start, and call SetDynamicInfo
again whenever updates are needed.
This guide will help you integrate Convai's WebGL capabilities into your Unity projects, enabling you to bring to life AI characters with human-like conversational abilities.
Convai's Unity WebGL SDK is designed to complement the standalone application capabilities of our Unity Asset Store version. With this specialized SDK, you can build and deploy interactive WebGL applications that leverage Convai's advanced conversation pipeline. Please see the instructions below or check out our latest tutorial video on YouTube.
Please ensure that Git is installed on your computer prior to proceeding. Download Git from here.
Follow the Import and Setup Instructions from Import and Setup (nightly) and Setting Up Unity Plugin.
When attempting to play the scene in the Unity Editor, you may encounter the following error:
This error occurs because the WebGL SDK cannot be tested directly within the Unity Editor. To test your WebGL application, you must create a development build.
Now, your Unity setup is done, let's setup WebGL
Head on over to File
→ Build Settings
, then:
Click on WebGL
.
Check the Development Build
box.
Select Switch Platform.
Patience, remember? This shift takes a bit.
After the platform is switched to WebGL, click on Player Settings
.This is where the fun begins:
Once the platform conversion is complete,
Open the filePlayer Settings
.
Navigate to the pageWebGL settings
.
Under theResolution and Presentation
tab, select theConvai PWA Template
.
After the reloads is completed, check if the settings have changed. then, close all the open menus and follow these steps :
Double-click the Convai folder
and go to scenes.
Open the Convey Demo WebGL
scene.
Head to Convai's website, grab your API key, and input it back in Unity via Convai
→ Convai Setup
.
Now, head again to the Convai’s website and grab your favourite character’s id and paste it to Convai
→ Character Importer
.
Remember, Unity's editor won't let us test WebGL directly. But fear not, there's a Build and Run
option:
Go back to File
→ Build Settings
.
Click Add Open Scenes
and then Build and Run
.
Choose a folder for the build output, make a new one if needed, and name it "WebGL."
The First build may take some time. For subsequent builds and runs, use the Unity shortcut key Ctrl + B.
The first build is the longest, so feel free to stretch a bit – but don't venture too far. Soon, you'll greet our demo character, Amelia, or any other character you brought into your digital oasis. Just give your Microphone permissions and here you go!
Now the magic happens. Press and hold 'T' to chat with your carefully cultivated character. Or click on the text box to type out a question. And for the attention to detail – press F10 to access the settings panel where you can change your name and the UI style to your liking.
Feeling accomplished? You should! You now have a successfully working WebGL build in your browser. Curious developers can take a step further by downloading the project files from GitHub, available for all who desire to peek behind the curtain.
When you are ready with your production build, just uncheck the Development Build field in the Build Settings before publishing
This guide will walk you through the process of installing Convai-powered Unity applications on iOS and iPadOS devices.
Before you begin, make sure you have the following:
Unity 2022.3 or later
Xcode (latest version recommended)
Apple Developer account
Project with Convai's Unity SDK integrated and running properly
MacBook for building and deploying to iOS/iPadOS
Open your Convai-powered Unity project.
In Unity, go to File
→ Build Settings
.
Select iOS
as the target platform.
Click Switch Platform
if it's not already selected.
Check the Development Build
option for testing purposes.
If you wish to add a few required files manually, follow step 3. If you want it to be done automatically, jump to step 4
Create a new file named link.xml
in your project's Assets
folder.
Add the following content to the file:
This file prevents potential FileNotFoundException
errors related to the libgrpc_csharp_ext.x64.dylib
file.
Create a new C# script in Assets/Convai/Scripts
named iOSBuild.cs
.
Add the following content to the script:
Go to Convai -> Custom Package Installer
Click on Install iOS Build Package
Attach the script iOSBuild.cs
to any GameObject in your scene.
In Unity, go to File
→ Build Settings
.
Click Build
and choose a location to save your Xcode project.
Wait for Unity to generate the Xcode project.
Open the generated Xcode project.
In Xcode, select your project in the navigator.
Select your target under the "TARGETS" section.
Go to the "Signing & Capabilities" tab.
Ensure that "Automatically manage signing" is checked.
Select your Team from the dropdown (you need an Apple Developer account for this).
If needed, change the Bundle Identifier to a unique string.
Connect your iOS device to your Mac.
In Xcode, select your connected device as the build target.
Click the "Play" button or press Cmd + R
to build and run the app on your device.
If you encounter any build errors, ensure all the steps above have been followed correctly.
Check that your Apple Developer account has the necessary provisioning profiles and certificates.
If you face any GRPC-related issues, verify that the libgrpc_csharp_ext.a
and libgrpc.a
files are correctly placed in the Assets/Convai/Plugins/gRPC/Grpc.Core/runtime/ios
folder.
Learn how to enable character retain conversation history across multiple sessions
Long-Term Memory (LTM) enables the persistent storage of conversational history with NPCs, allowing players to seamlessly continue interactions from where they previously left off, even across multiple sessions. This feature significantly enhances the realism of NPCs, aligning with our goal of creating more immersive and lifelike characters within your game.
Prerequisite: Have a project with Convai SDK version 3.1.0 or higher. If you don't have it, check this documentation
Select your Convai Character
Add the Long-Term Memory Component onto your character
Make sure that Long Term Memory is enabled for that character
Long Term Memory should now be working for your character.
This component will enable or disable LTM right from the unity editor
Toggling Long Term Memory
1) Click the button provided in the component
2) It will take some time to update, and after that the new status of the LTM should be visible in the inspector.
Since enabling or disabling Long-Term Memory (LTM) for a character is a global action that impacts all players interacting with that character, we strongly recommend against toggling the LTM status at runtime. This functionality should be managed exclusively by developers or designers through the editor to ensure consistent gameplay experiences.
Grpc.Core.RpcException: Status(StatusCode=InvalidArgument, Detail="Cannot find speaker with id: 99fbef96-5ecb-11ef-93ce-42010a7be011.")
If you encounter this error, ensure that the SpeakerID was created using the same API key currently in use. If you're uncertain about the API key used, you can reset the SpeakerID and PlayerName by accessing the ConvaiPlayerDataSO
file located in Assets > Convai > Resources
, allowing you to start the process anew.
It is essential for developers to efficiently manage the Speaker ID(s) generated using their API key, as the number of IDs that can be created is limited and dependent on the subscription tier. Proper management ensures optimal usage of resources and prevents potential disruptions in the application's functionality.
Personal
1
Gamer / Indie / Professional
5
Partner / Enterprise
100 (Can be Customized)
You can view all the Speaker ID(s) associated with a specific API key by accessing the Convai Window within your Unity project. This feature provides a comprehensive list of IDs, allowing for easier management and monitoring.
Ensure that the API key is correctly entered; otherwise, the feature will not function as expected. Accurate API key input is critical for accessing and managing Speaker ID(s) through the Convai Window in Unity.
Head over to Long Term Memory Section
If the message "No Speaker ID(s) Found" appears, there is no need to proceed with this guide. However, if a Speaker ID list is displayed, it's advisable to delete any ID(s) that are no longer in use or needed to optimize your available resources.
Automatic Installation Steps
The Automatic Installation method is ideal for users starting new projects who want a straightforward setup. It provides a fully integrated Convai MR project from the beginning, ensuring a smoother development experience.
In the top menu, click on Convai. Then, select Custom Package Installer.
In the Convai Panel that appears, click on Package Management and then select Install MR Package.
A new window will appear prompting you to select your installation type. For this documentation, we will proceed with Automatic Installation.
In the next window, carefully read the setup instructions, warnings, and details of the changes that will be applied.
When ready to proceed, click Yes, proceed.
The installation process will begin, taking approximately 5 minutes. The duration may vary depending on your computer's performance.
If a prompt titled OVRPlugin Detected from MetaSDK appears, click Restart Editor to continue.
Once the installation is complete, it’s time to open the demo scene.
Navigate to Assets > Convai > ConvaiXR > ConvaiMR > Scenes and open Convai Demo - MR.
If you don’t have the TextMeshPro package installed, you’ll need it to display text properly in the demo scene. To install it:
Go to Window > TextMeshPro > Import TMP Essential Resources.
In the Unity Package Import window that appears, click Import.
You can build your project by going to File > Build Settings.
In the demo scene, select [BuildingBlock] Find Spawn Positions in the hierarchy.
In the Spawn Object field, drag and drop the character you imported into the project.
If you’re unsure how to import your character, please refer to the relevant documentation here.
This demo scene uses MetaSDK by default. However, you are free to use other methods or SDKs to spawn your character, as there are no restrictions.
macOS security permission issue with custom DLLs in Unity and Mac Configuration in build settings
Using external DLLs in Unity on MacOS can lead to security permission issues due to Apple's strict security measures. Here's a step-by-step guide to resolving this common problem.
Verify the Problem:
Manually Allow Blocked DLLs:
Open System Preferences on your Mac.
Navigate to "Security & Privacy".
Under the "Security" tab, you might see a message at the bottom about the DLL being blocked. Click "Allow Anyway" or "Open Anyway" and enter password if asked.
Modify Gatekeeper settings: MacOS's Gatekeeper can prevent unidentified developers' software from running. To allow the DLL:
Open the Terminal (found in Applications > Utilities).
Type sudo spctl --master-disable
and press Enter.
This command will allow apps to be downloaded from anywhere.
Now, try running the Unity project again.
After you're done, you should re-enable Gatekeeper with sudo spctl --master-enable
to avoid any malware.
Check File Permissions: Ensure the DLL has the correct file permissions.
In Finder, right-click (or control-click) on the DLL file and choose "Get Info".
Under “Sharing & Permissions”, ensure that your user account has "Read & Write" permissions.
Review Unity's Plugin Settings:
In the Unity editor, select the DLL in the Project view.
In the Inspector window, make sure the appropriate platform (in this case, Mac OS X) and architecture (Apple Silicon, Intel-64) is selected for the DLL.
Ensure that the "Load on Startup" and other pertinent options are checked (should be enabled by default)
Update Mac Configuration:
In Unity, navigate to Edit > Project Settings > Player
.
Scroll down and click on Other Settings
Scroll down again to find Mac Configuration section
Update the Mac Configuration section (follow the below Screenshot)
Building for AR - Unity Plugin Guide for AR development with Convai.
If you want to make your Convai Plugin compatible with AR, you can do so in two ways. Please see the instructions below or check out our latest tutorial video on YouTube.
Recommended for new projects.
The following processes will be performed:
Universal Render Pipeline (URP)
ARCore Plugin
Convai Custom AR Package
Convai URP Converter
If these packages are not present, they will be installed.
If the target build platform is not Android, it will be switched to Android.
Make sure to download the Android platform support from Unity Hub for your project's version.
Click on " Convai / Convai Custom Package Installer / Install AR Package "
Confirm the changes and processes to be made. If you agree, the process will start. Click " Yes, Proceed " and the process will begin. You'll see logs in the console.
If you encounter an error like "Failed to Resolve Packages," don't worry. The process will continue, and the error will be resolved automatically after the package installations are complete.
Open the " Convai / Scenes / Convai Demo - AR " demo scene. If the TMP Importer window appears ( It will appear if TMP Essentials is not installed in your project ), click " Import TMP Essentials " to install TextMeshPro Essentials for UI text objects.
Alternatively, you can use the " Window / TextMeshPro / Import TMP Essential Resources " to install it.
After importing TMP Essentials, you can remove the empty GameObject in your scene that triggers the Prompt window to appear.
Build your project by going to " File / Build Settings / Build " Ensure that the " Convai Demo - AR " scene is included in the Scenes in Build section.
Ensure you've set up your API Key. ( Convai / Convai Setup )
Now everything is ready for testing. 🙂✅
Ensure you have the following packages installed in your project:
ARCore
URP (Universal Render Pipeline) - Recommended for optimization, though not mandatory
Double-click on " Convai / Convai Custom Unity Packages / ConvaiVRUpgrader.unitypackage "
You'll see a warning that the settings will overwrite your project settings. You can either allow it by clicking " Import " or create a temporary project by clicking " Switch Project "
In the Import Unity Package window, review the assets to be imported and click " Next "
Select all settings to be changed in the Project Settings and complete the installation by clicking " Import "
Open the " Convai / Scenes / Convai Demo - AR " demo scene. If the TMP Importer window appears ( It will appear if TMP Essentials is not installed in your project ), click " Import TMP Essentials " to install TextMeshPro Essentials for UI text objects.
Alternatively, you can use the " Window / TextMeshPro / Import TMP Essential Resources " to install it.
After importing TMP Essentials, you can remove the empty GameObject in your scene that triggers the Prompt window to appear.
If you see 3D objects in pink, it's a shader issue. If you're using URP, convert the materials to URP by double-clicking on " Convai / Convai Custom Unity Packages / ConvaiURPConverter " and importing all assets in the window that appears.
Ensure you've set up your API Key ( Convai / Convai Setup ).
Build your project by going to " File / Build Settings / Build " Ensure that the " Convai Demo - AR " scene is included in the Scenes in Build section.
Now everything is ready for testing. 🙂✅
If you've created a Ready Player Me character on convai.com playground and want to add it to your AR project, follow these steps:
Right-click on the " Convai / ConvaiAR / Prefabs / Convai NPC AR Base Empty Character " prefab.
Click on " Create / Prefab Variant "
You'll see a prefab variant created for " Convai NPC AR Base Empty Character "
Double-click on this prefab variant.
In the Hierarchy section, add your imported character as a child to this prefab variant.
Use the " Importing RPM Characters " guide to add your character to your project.
After adding your character, click on your character.
In the Inspector, adjust the Scale settings as needed. To prevent your character from moving with animation while talking, disable the " Apply Root Motion " option in the Animator.
After these steps, save your prefab variant by pressing CTRL + S.
Open the " Convai / Scenes / Convai Demo - AR " scene.
Click on the " Convai AR Player " object under " ConvaiAR Base Scene "
In the Inspector, under the " Convai Character Spawner " component, add your prefab variant to the Character Prefab field.
Now, everything is ready to test your character in the AR environment!🙂✅
Creating this prefab variant is to prevent automatic scaling ( 1,1,1 ) of your prefab when instantiated in the AR environment.
To avoid issues with scale adjustments, we added our character as a child to an empty parent object. For convenience, we created an empty prefab variant.
Transcript UI System - Integrate transcript UI with Convai's Unity plugin.
The Dynamic UI system is a feature within the Convai Unity SDK that provides developers a robust system for in-game communication. This feature allows for displaying messages from characters and players and supports various UI components for chat, Q&A sessions, subtitles, and custom UI types. This document will guide you through the integration, usage, and creation of custom UI types of the Dynamic UI feature in your Unity project.
To interact with the chat system, you need to reference the ConvaiChatUIHandler
in your scripts. You can find the Transcript UI prefab in the Prefabs folder.
Here's an example of how to find and assign the handler:
Once you have a reference to the ConvaiChatUIHandler
, you can send messages using the following methods:
Sending Player Text
To send text as the player:
input
: The string containing the player's message.
To send text as a character:
characterName
: The name of the character sending the message.
currentResponseAudio.AudioTranscript
: The transcript of the audio response from the character, trimmed of any leading or trailing whitespace.
While the Dynamic UI system within the SDK provides several pre-built UI types, you may want to create a custom UI that better fits the style and needs of your game and it designed to be extensible, allowing developers to add their custom UI types. This is achieved by inheriting from the ChatUIBase
class and implementing the required methods. The ConvaiChatUIHandler
manages the different UI types and provides a system to switch between them.
To create a custom UI type, follow these steps:
Create a new C# script in your Unity project and define your class to inherit from ChatUIBase
. For example:
Implement the abstract methods from ChatUIBase
. You must provide implementations for Initialize
, SendCharacterText
, and SendPlayerText
:
Add any additional functionality or customization options that your custom UI may require.
To use your custom UI class within the dictionaryConvaiChatUIHandler
, you need to add it to the GetUIAppearances
dictionary. This involves creating a prefab for your custom UI and assigning it in the ConvaiChatUIHandler
.
Here's an example of how to do this:
Create a prefab for your custom UI and add your CustomChatUI
component to it.
Assign the prefab to a public variable in the ConvaiChatUIHandler
script.
Modify the InitializeUIStrategies
method in the ConvaiChatUIHandler
script to include your custom UI type.
Ensure that your custom UI type is added to the UIType
enum:
Now you can set your custom UI type as the active UI from the Settings Panel Settings Panel.
By following these steps, you can integrate your custom UI type into the Dynamic Chatbox system and switch between different UI types at runtime.
Everything is now set up!
Everything is now set up!
Everything is now set up!
This feature provides a powerful tool for creating NPC interactions that respond in real-time to the state of the game world, creating a more immersive experience for the player.
Everything is now set up!