カスタムアニメーションを適用する方法
外部アニメーションファイルをインポートし、それをZEPETOキャラクターに適用する方法を学びましょう。
アニメーションをダウンロードしたいサイトにアクセスします。 このガイドはMixamoサイトの使用例です。
📘 Mixamo
希望のヒューマノイドアニメーションをクリックします。

アニメーションをダウンロードし、「FBX for Unity (.fbx)」オプションを選択します。

ダウンロードしたファイルをUnityプロジェクトパネルにドラッグアンドドロップします。

リグタブをクリックし、アニメーションタイプをヒューマノイドに変更します。

❗️ 注意
ヒューマノイド設定がないと、ZEPETOキャラクターと互換性がありません。 設定を確認してください。
アニメーション > モーション > ルートモーションノードオプションを<Root Transform>に変更して、キャラクターのアニメーションをよりスムーズでリアルにします。

📘 Unity ルートモーションノードの選択
ZepetoPlayersコンポーネントインスペクター内のアニメーター変数に関連付けられたアニメーターオブジェクトをクローンします。
- ファイルパス : Packages/zepeto.character.controller/Runtime/_Resources/AnimatorController/ZepetoAnimatorV2.controller
- アニメーターをアセットフォルダーにドラッグします。
コピー後、ZepetoAnimatorV2_Customに名前を変更します。
階層 > ZEPETO > ZepetoPlayersをクリックして作成し、ZepetoPlayersコンポーネントのAnimation Controllerフィールドに作成したアニメーターのコピーをドラッグします。

ZepetoAnimatorV2_Customをダブルクリックしてアニメータータブを開きます。
新しいアニメーションをアニメーターにドラッグ&ドロップしてアニメーションステートを作成します。
作成したアニメーションステートを右クリックし、次に「遷移を作成」をクリックしてIdleステートに戻る遷移を作成します。

ボタンをクリックしたときにアニメーションを再生する例を作成しましょう。

階層 > UI > ボタンを追加します。
- 階層を作成 > 空のオブジェクトを作成し、CharacterControllerに名前を変更します。
- プロジェクトを作成 > 作成 > ZEPETO > TypeScriptを選択し、CharacterControllerに名前を変更します。
- 以下のようにサンプルスクリプトを書きます:
- スクリプトの流れは次のとおりです:
- Start()
- playCustomAnimationButtonにリスナーを追加し、クリック時にアニメーションを再生します。
- ZepetoPlayers.instance.CreatePlayerWithUserId()関数を呼び出してローカルプレイヤーを作成します。
- ローカルプレイヤーのアニメーターコンポーネントを取得し、localPlayerAnimator変数に格納します。
- カスタムアニメーションクリップに設定されたアニメーションクリップを割り当てます。
ボタンをドラッグして、カスタムアニメーションボタンに割り当てます。
6. アニメーションを再生するためにボタンをクリックします。
👍 ZEPETOキャラクター以外のカスタムキャラクターを使用する場合、
ヒューマノイドキャラクターであれば、ZEPETOアニメーションを適用できます。