Installation
在 Unity 專案中匯入 .unitypackage 檔案;
前往根目錄的
EntityPrototype
遊戲物件,並新增AnimatorMecanim
指令碼:

- 在同一個物件或子物件中新增一個空的 Unity Animator 元件:

- 在您偏好的資料夾中,創建一個新的
AnimatorGraph
資產:

- 選取該資產,並在
Controller
欄位中,引用需要
內嵌的 Unity 動畫控制器:

- 點擊
Bake Animator Graph
按鈕,狀態、過渡、參數等將被內嵌到資產中:

- 在 Entity Prototype 中,新增
AnimatorComponent
,並在Animator Graph
欄位中引用您偏好的資產:

- 在
SystemConfig
資產中,新增 AnimatorSystem、AnimatorBehaviourSystem 和 AnimatorTriggersSystem 系統:

- 在遊戲場景中創建一個新的遊戲物件,並新增
AnimatorViewUpdater
元件到它:

- 這是初始設定。在模擬中使用動畫控制器 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
- 確保您已備份專案。
- 刪除
QuantumUser/Simulation/QuantumCustomAnimator
。 - 刪除
QuantumUser/View/CustomAnimator
。 - 刪除
Scripts/QuantumCustomAnimator
。 - 匯入
QuantumAnimator.unitypackage
。 - 在所有使用
CustomAnimator
的指令碼中,將其替換為AnimatorComponent
。 - 從
Frame.User
刪除Custom.Animator.AnimatorUpdater
。
替換 CustomAnimatorGraph
如果CustomAnimatorGraph
資產無法正常工作,請按照以下步驟操作:
- 將 Inspector 切換到 Debug 模式。
- 選取資產並移除附加的
Controller
。 - 點擊
Import Mecanim Controller
。 - 重新附加
Controller
,並再次點擊Import Mecanim Controller
;