Adding Actions to your Character

Follow these instructions to enable actions for your Convai-powered characters.

Setting Up Action Configurations

  1. Select the Convai NPC character from the hierarchy.

  2. Scroll down to the ConvaiNPC script attached to your character.

  3. Click the "Add Component" button.

  1. Use the checkbox to add the action script to the NPC Actions.

  2. Click "Apply Changes" to confirm.

Pre-defined Actions

Convai offers predefined actions for a quick start.

  1. Click the "+" button to add a new action.

  2. From the dropdown menu, select "Move To."

  1. Enter the action name as "Move To" (the name doesn't have to match the action choice name).

  2. Leave the Animation Name field empty for now.

Repeat these steps to add more actions like "Pickup" and "Drop" etc.

Adding an Object in the Scene

  1. Add any object into the scene—a sphere, a cube, a rock, etc.—that can be interacted with

  2. Resize and place the object in your scene.

Adding the Convai Interactables Data Script

  1. Attach the Convai Interactables Data script to this GameObject.

  2. Add characters and objects to the script by clicking the "+" button and attaching the corresponding GameObjects.

Test the Setup

  1. Click "Play" to start the scene.

  2. Ask the NPC, "Bring me the Box."

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

Adding Custom Actions to Your Unity NPC in Convai

Introduction

Make your NPC perform custom actions like dancing.

Action that Only Requires an Animation

  1. Locate the dance animation file within our plugin.

  2. Incorporate this animation into your NPC's actions.

Setting Up the Animator Controller

  1. Open the Animator Controller from the Inspector window.

  2. Drag and drop the dance animation onto the controller, creating a new node named "Dancing."

Adding custom Animation Action

  1. Go to the Action Handler Script attached to your Convai NPC.

  2. Add a new action named "Dancing."

  3. In the Animation Name field, enter "Dancing" (it must exactly match the Animator Controller node name).

  4. Leave the enum as "None."

Testing the Custom Action

  1. Click "Play" to start the scene.

  2. Instruct the NPC, "Show me a dance move," and the NPC should start dancing.

Creating Complex Custom Actions in Unity with Convai: Throwing a Rock

Introduction

Adding advanced custom actions, such as a throw action, to your NPC.

Animation Requirement

  1. Grab a throw animation from Mixamo or anywhere you like.

  2. Import it into Unity.

Setting Up the Animator Controller

  1. Drag and drop the throw animation onto the controller, creating a new node named "Throwing." (Follow steps in Action that Only Requires an Animation)

Action Handler Script Setup

  1. Add the "Throw" enum to the script.

  2. In the "Do Action" function, add a switch case for the throw action.

  3. Define the "Throw()" function.

Adding the Throw Action

  1. Add a new action named "Throw" and select the "Throw" enum.

  2. Leave the animation name field empty.

Adding the Object (Rock) to the Convai Interactables Data script

  1. Add any rock prefab into the scene.

  2. Add the rock to the Convai Interactable Data script.

Adding a location to Convai Interactables Data script

  1. Add a stage/new location in the ground of the scene.

  2. Add that new location game object in the Convai Interactable Data.

Testing the Complex Action

  1. Click "Play" to start the scene.

  2. Instruct the NPC, "Pick up the rock and throw it from the stage."

  3. If everything is set up properly, the NPC should pick up the rock and throw it from the stage.


Last updated