Links

Adding Actions to your Character

Follow these instructions to enable actions for your Convai-powered characters.
This feature is currently experimental and can misbehave. You are free to try it out and leave us any feedback.
The actions version of the plugin is a fork of the RPM Version of the plugin. This means that you can easily import characters and play around with them. To use custom characters with the actions version, first set up the character with Convai.
After setting it up, add the script name ConvaiActionsHandler.cs to the GameObject. This script keeps track of all the actions that the character can do along with an enum that is used internally to trigger the functions corresponding to the actions.
Add the ConvaiGlobalActionSettings.cs to an empty GameObject in the scene. This script will contain all the interactable objects and characters in the scene.
Add the following fields:
Field
Description
Characters (in Convai Global Action Settings)
Characters that are present in the scene. Add the GameObject of the Character and the Description of the Character.
Objects (in Convai Global Action Settings)
Interactable Objects that are present in the scene. Add the GameObject of the Interactable Object and the Description of the object.
Action Methods (in Convai Actions Handler)
Actions that can be performed by the character.
Add the ActionChoice describing the action and the name of the animation state corresponding to the action (the animation must be present in the animator).

Adding Custom Actions

To add custom actions, edit the ConvaiActionsHandler.cs script.
If your action is cosmetic and is only an animation, you do not need to edit the code. Simply select the Action Choice None.
Add the ActionChoice enum at the beginning to identify the action in script.
1
// STEP 1: Add the enum for your custom action here.
2
public enum ActionChoice
3
{
4
NONE,
5
JUMP,
6
CROUCH,
7
MOVE_TO,
8
PICK_UP,
9
DROP,
10
DANCE,
11
// add your action choice enum here.
12
}
Add the Function call corresponding to the action and the ActionChoice enum in the switch case in the DoActions() function.
public IEnumerator DoAction(ConvaiAction action)
{
// STEP 2: Add the function call for your action here corresponding to your enum.
// Remember to yield until its return if it is a Enumerator function.
switch (action.verb)
{
case ActionChoice.MOVE_TO:
yield return MoveTo(action.target);
break;
case ActionChoice.PICK_UP:
yield return PickUp(action.target);
break;
case ActionChoice.DROP:
Drop(action.target);
break;
case ActionChoice.DANCE:
yield return Dance();
break;
case ActionChoice.JUMP:
Jump();
break;
case ActionChoice.CROUCH:
yield return Crouch();
break;
// Add a new case with the ActionChoice Enum.
// Call the function in this Case.
case ActionChoice.NONE:
yield return AnimationActions(action.animation);
break;
default:
break;
}
yield return null;
}
Add the Function that the action will be doing at the end.
Now, add the corresponding animation to the Animator. Take note of the animation state.
Add the animation for the new action.
Finally, in the Action Methods add the action information.
Add the new action information to the action methods array.
If your action is cosmetic and is only an animation, you do not need to edit the code. Simply select the Action Choice None.