This document is about: QUANTUM 3
SWITCH TO

Installation

  1. 在 Unity 專案中匯入 .unitypackage 檔案;

  2. 前往根目錄的EntityPrototype遊戲物件,並新增AnimatorMecanim指令碼:

Adding Animator to Prototype
  1. 在同一個物件或子物件中新增一個空的 Unity Animator 元件:
Adding Unity Animator
  1. 在您偏好的資料夾中,創建一個新的AnimatorGraph資產:
AnimatorGraph creation
  1. 選取該資產,並在Controller欄位中,引用需要
    內嵌的 Unity 動畫控制器:
Unity controller reference
  1. 點擊Bake Animator Graph按鈕,狀態、過渡、參數等將被內嵌到資產中:
Baking Animator Graph
  1. 在 Entity Prototype 中,新增AnimatorComponent,並在Animator Graph欄位中引用您偏好的資產:
Adding AnimatorComponent
  1. SystemConfig資產中,新增 AnimatorSystem、AnimatorBehaviourSystem 和 AnimatorTriggersSystem 系統:
Adding Systems
  1. 在遊戲場景中創建一個新的遊戲物件,並新增AnimatorViewUpdater元件到它:
Adding AnimatorViewUpdater
  1. 這是初始設定。在模擬中使用動畫控制器 API,例如在運行時設置動畫參數值,即可開始確定性動畫。

基本 API 與 Unity 中的使用方式類似,使用 Getter 和 Setter 來讀取/寫入動畫控制器:

C#

// Getters
AnimatorComponent.GetBoolean(frame, filter.AnimatorComponent, "Defending");
AnimatorComponent.GetFixedPoint(frame, filter.AnimatorComponent, "Direction");
AnimatorComponent.GetInteger(frame, filter.AnimatorComponent, "State");

// Setters
AnimatorComponent.SetBoolean(frame, filter.AnimatorComponent, "Defending", true);
AnimatorComponent.SetInteger(frame, filter.AnimatorComponent, "Direction", 25);
AnimatorComponent.SetFixedPoint(frame, filter.AnimatorComponent, "Speed", FP._1);
AnimatorComponent.SetTrigger(frame, filter.AnimatorComponent, "Shoot");

替換舊版 Custom Animator

  1. 確保您已備份專案。
  2. 刪除QuantumUser/Simulation/QuantumCustomAnimator
  3. 刪除QuantumUser/View/CustomAnimator
  4. 刪除Scripts/QuantumCustomAnimator
  5. 匯入QuantumAnimator.unitypackage
  6. 在所有使用CustomAnimator的指令碼中,將其替換為AnimatorComponent
  7. Frame.User刪除Custom.Animator.AnimatorUpdater

替換 CustomAnimatorGraph

如果CustomAnimatorGraph資產無法正常工作,請按照以下步驟操作:

  1. 將 Inspector 切換到 Debug 模式。
  2. 選取資產並移除附加的 Controller
  3. 點擊Import Mecanim Controller
  4. 重新附加Controller,並再次點擊Import Mecanim Controller
Back to top