Adding New Animations to NPCs dialogues

From RPG Creation Kit
Jump to navigation Jump to search

In this tutorial we are going to see how to add a new animation that NPCs can play while using the dialogue system.

The NPCs can use animations for both talking and listening, the process of adding each one of these is the same, as described here.

I am going to add an animation taken from Mixamo.com

Import the animation

New Animation's import settings.

The first step is obviously to import the animation in your project.

Make sure in the import settings to use as Animation Type "Humanoid". You can choose "Create From This Model" as the avatar definition if you don't have any compatible skeleton with that one animation.


You can also set in the "Animation Tab" whether the animation has to loop or not, for dialogue lines that will take more seconds than the animation time.



Add the animation to the NPCs Animator

Second step is even easier. Open the TPS_Base animator, which defines all the animations for NPCs and look at the left-bottom of the default state (Base Locomotion), you will find all the animations used by the NPCs to dialogue in the RCK.

You just need to add your own to the list, name it meaningfully - as its name will be used later and make sure to add the return state to the default one.

The return state should have "Has Exit Time" set to false, and as conditions the triggering of "CancelDialogueAnimation", refer to the image below:

I named my new animation "Talking_NewAnim".

NDA 6.png

Adding the Animation to the Dialogue Animations list

The last step is adding the new animation name to the Dialogue Animation List.

Open the file "NPCDialogueLineNode.cs" and look for the array "DIALOGUE_ANIMATIONS".

All you have to do is to insert the name of the animation we just added, and remember that it must be the same as the name of the animation state you've set, in my case "Talking_NewAnim":

NDA 4.png

Using your animation

At this point it's all done!

Next time you will open the Dialogue System, your new animation will be available to choose for both listening or talking;

Tess using the new animation.

NDA 5.png

Troubleshooting

If you have any issues, like a warning "Invalid Layer Index '-1'", it's very likely that you have a spelling error in either the Animator state or the DIALOGUE_ANIMATIONS array, double check and correct it if it is the case.