> 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 将你导入的带有自定义模型的角色进行设置。

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

## 前提条件

要使用 Convai 设置自定义角色，需要准备角色模型和两个动画：待机和说话。

创建一个包含这两个动画的 Animator Controller，效果如下所示。还需要添加一个“Talk”布尔值，以便触发动画。 [这里有一个 YouTube 教程，介绍如何设置 Animator Controller](https://www.youtube.com/watch?v=JeZkctmoBPw\&t=53s)。这是所需的最低限度 Animator 设置。

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FQj753RXbB7f1Ymc2zd6I%2Fimage.png?alt=media&amp;token=a6076dda-3f0c-46af-8c40-e865da2f34a5" alt=""><figcaption><p>Animator Controller 应如下所示。这是内置的 NPC Animator。</p></figcaption></figure>

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

在 Hierarchy 中选择角色，然后添加 Animator 组件

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FTzrYC6rl02cgC08wcboa%2FScreenshot%202024-05-23%20195315.png?alt=media&amp;token=d77aac8b-2ac6-4584-844a-78a28a5810a2" alt=""><figcaption><p>显示新添加的 Animator 组件的截图</p></figcaption></figure>

Convai 插件附带两个预制的动画控制器。你可以选择使用这些控制器，也可以指定自己的控制器，按需选择即可。本示例将使用 `Feminine NPC Animator`

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FOS3lj5DS5SZPWoik1H42%2FScreenshot%202024-05-23%20195607.png?alt=media&amp;token=45093646-82e0-4f05-a92a-673d70fc0044" alt=""><figcaption><p>显示动画控制器选择过程的截图</p></figcaption></figure>

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

选中自定义角色后，添加一个你选择的碰撞体。本示例将使用 `Capsule Collider`

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FYKxA2s27ZKEX42h72OQA%2FScreenshot%202024-05-23%20200002.png?alt=media&amp;token=1fbc4270-0548-422d-891f-e8ec6ee30233" alt=""><figcaption><p>显示新添加的 Capsule Collider 的截图</p></figcaption></figure>

我们将把此碰撞体设为触发器。为此，请启用 `Is Trigger` 检查器面板中的选项

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2F0zSKh2rRXqYbnHh5A6Do%2FScreenshot%202024-05-23%20200219.png?alt=media&amp;token=7dfad8d7-f06e-47fa-8b9d-1b69aaed1313" alt=""><figcaption><p>显示已启用 Is Trigger 选项的截图</p></figcaption></figure>

调整碰撞体的中心、半径和高度，使其贴合角色。

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FGCGZc4qZ6lZ164Xjq8Rw%2FScreenshot%202024-05-23%20203103.png?alt=media&amp;token=c92b6eca-b0f4-459e-ad6f-bf6ee7ba760f" alt=""><figcaption></figcaption></figure>

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

选中自定义角色后，添加 ConvaiNPC 组件。完成后，游戏对象应如下所示：

{% hint style="info" %}
这里假设你只添加了前面说明的组件；你的游戏对象组件列表可能会有所不同。
{% endhint %}

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FCALznCPgACXOc3En6yxj%2FScreenshot%202024-05-23%20201324.png?alt=media&amp;token=4379aab2-34af-4522-9661-883ffd7f14dc" alt=""><figcaption><p>显示新添加的 ConvaiNPC 组件的截图</p></figcaption></figure>

从以下位置复制角色的 ID 和名称： [Convai Playground](https://docs.convai.com/api-docs/zh/convai-playground/get-started.md) 并将其粘贴到此处。

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FPqKoJG9Q7Hp9NaMNOHK9%2FScreenshot%202024-05-23%20201727.png?alt=media&amp;token=fa46d206-1fa8-495f-9312-dfaee24abed2" 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
