> For the complete documentation index, see [llms.txt](https://docs.convai.com/api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/unity-plugin/importing-custom-characters.md).

# 导入自定义角色

要将你的自定义角色导入到由 Convai 驱动的 Unity 项目中，你首先需要将模型导入到项目中。该模型至少需要两个动画：一个用于说话，一个用于待机。

## 先决条件

当你想要使用 Convai 设置自定义角色时，你需要角色模型以及两个动画：待机（Idle）和说话（Talking）。

创建一个带有这两个动画的 Animator Controller，如下所示。你还应该添加一个“Talk”布尔值，以确保可以触发该动画。 [这里有一个关于如何设置 Animator Controller 的 YouTube 教程](https://www.youtube.com/watch?v=JeZkctmoBPw\&t=53s)。这就是你需要完成的最基本 Animator 设置。

<figure><img src="/files/f11f9ae9ec0949a8c3649e3828072684e686bdec" alt=""><figcaption><p>Animator Controller 应该像这样。这是内置的 NPC Animator。</p></figcaption></figure>

### 步骤 1：为你的自定义角色添加 Animator

从 Hierarchy 中选择你的角色，并添加 Animator 组件

<figure><img src="/files/d9793159bc9f746bb9840ceb52c60ca0849de0ce" alt=""><figcaption><p>显示新添加的 Animator 组件的截图</p></figcaption></figure>

Convai 插件附带两个预制的动画控制器，你可以选择这些控制器，也可以分配你自己的自定义控制器，按你的需求即可。对于这个演示，我们将使用 `女性 NPC Animator`

<figure><img src="/files/e01389567b76532d981080ed9af7cc337eb9a4f3" alt=""><figcaption><p>显示选择 Animation Controller 的截图</p></figcaption></figure>

### 步骤 2：添加触发器体积

选中你的自定义角色后，添加任意你喜欢的碰撞形状，对于这个演示我们将使用一个 `胶囊碰撞器`

<figure><img src="/files/ff7775dd0c52f4bb29fe44275763f21ff6ccc88b" alt=""><figcaption><p>显示新添加的胶囊碰撞器的截图</p></figcaption></figure>

我们将把这个碰撞器设置为触发器，为此我们将启用 `触发器` 在检视器面板中的选项

<figure><img src="/files/d7ef849873fd46a12720f860952cd05247dd744c" alt=""><figcaption><p>显示启用 Is Trigger 选项的截图</p></figcaption></figure>

我们将调整碰撞器的 Center、Radius 和 Height，使其适配我们的角色

<figure><img src="/files/1f692597f5f98e5f1fc2f9259c1eab627cfec205" alt=""><figcaption></figcaption></figure>

### 步骤 3：添加 ConvaiNPC 组件

在你的自定义角色上添加 ConvaiNPC 组件。这样一来，你的 Game Object 应该会像这样：

{% hint style="info" %}
我们假设你没有添加任何除预先说明的组件之外的内容；你的 Game Object 组件列表可能会有所不同
{% endhint %}

<figure><img src="/files/43c9cc3b49c37bed1bc321ca26d0917398d51b17" alt=""><figcaption><p>显示新添加的 ConvaiNPC 组件的截图</p></figcaption></figure>

从 [Convai Playground](/api-docs/zh/convai-playground/get-started.md) 复制你角色的 ID 和名称，并粘贴到这里。

<figure><img src="/files/78821dc9e7dc2a0cef37a063114811684136dd05" alt=""><figcaption><p>显示已填写角色信息的截图。</p></figcaption></figure>

现在你的自定义角色已经全部设置完毕，可以与 Convai 插件一起工作了。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/unity-plugin/importing-custom-characters.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
