Adding Actions to your Character
Follow these instructions to enable actions for your Convai-powered characters.
Last updated
Follow these instructions to enable actions for your Convai-powered characters.
Last updated
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.
Add the Dynamic Move Target Indicator and setup NavMesh agent to you NPC.
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.
Grab a throw animation from Mixamo or anywhere you like.
Import it into Unity.
Drag and drop the throw animation onto the controller, creating a new node named "Throwing." (Follow steps in Action that Only Requires an Animation)
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.