Files
test/Assets/PerfectWorld/Scripts/_Doc/AnimationSceneSkillTest.md
T

189 lines
7.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Animation Test Scene — Skill Animation Workflow
**Scene:** [`Assets/PerfectWorld/Scene/AnimationTest.unity`](Assets/PerfectWorld/Scene/AnimationTest.unity)
Use **AnimatedModifier**, **LogPanel**, and **SkillPanel** to load a character, pick a skill, and verify **cast + attack animations** and **GFX path coverage** without a server.
**See also:** [`AnimationSceneSetup.md`](AnimationSceneSetup.md) (runtime APIs), [`AnimationSceneEditor.md`](AnimationSceneEditor.md) (bootstrap inspector tools).
---
## Scene objects
| Hierarchy name | Component | Script |
|---|---|---|
| **AnimatedModifier** | `AnimScenePlayerBootstrap` | `Assets/PerfectWorld/Scripts/AnimTestScene/AnimScenePlayerBootstrap.cs` |
| **LogPanel** | `LogPanelAnimeScene` | `Assets/PerfectWorld/Scripts/AnimTestScene/LogPanelAnimeScene.cs` |
| **SkillPanel** | `SkillTriggerPanel` | `Assets/PerfectWorld/Scripts/Debug/SkillTriggerPanel.cs` |
---
## Prerequisites
The scene must include the managers from `AnimationSceneSetup.md` (§911):
- `AutoInitializer` / `ElementDataManProvider`
- `NPCManager`, `CECAttacksMan`, `EC_ManMessageMono`
- **CECHostPlayer** (referenced by AnimatedModifier and SkillPanel)
- UI init so `CECUIManager` / `CECGameUIMan` is ready (skill icons)
**AnimatedModifier** must not be on the same GameObject as `CECHostPlayer` if **Replace host on role switch** is enabled.
---
## Inspector wiring
### AnimatedModifier (`AnimScenePlayerBootstrap`)
| Field | Assign |
|---|---|
| **Player** | Scene `CECHostPlayer` |
| **Camera Object** | Main camera |
| **Camera Poses** | Preset transforms for orbit views |
| **Initial Role** | Default profession + gender on Play |
| **Weapon By Action Type** | 15 slots (index = `action_type` / `m_uAttackType`) |
| **Active Weapon Action Type Index** | Slot applied after each load |
| **Anim Scene Avoid Fashion Weapon Config Path** | On (recommended) |
| **Bind Player Visual After Model Load** | On (required for `PlayActionEvent` / Animancer) |
| **Is Evil Skill Path** | God vs evil catalog (same as `CDlgSkillSubList`) |
| **Skill Catalog Level** | Level for `CECHostSkillModel` injection (default `1`) |
**Scene UI (camera):**
| Button | Typical `OnClick()` target |
|---|---|
| **NextView** | `AnimatedModifier``AnimScenePlayerBootstrap.ChangeNextCamera()` |
| **PreviosView** | `AnimatedModifier``AnimScenePlayerBootstrap.ChangePreviosCamera()` |
These cycle **Camera Poses** and reparent **Camera Object** (wraps at ends of the list).
**Play Mode inspector** (select AnimatedModifier): **Switch model**, **Play action**, **Re-apply active weapon slot**.
### SkillPanel (`SkillTriggerPanel`)
| Field | Assign |
|---|---|
| **Player** | Same `CECHostPlayer` as AnimatedModifier |
| **Target Marker** | `CECMonsterTest` in front of the player |
| **Skill Grid Container** | `RectTransform` + `GridLayoutGroup` |
| **Skill Button Prefab** | Button + Image (icon) + Text |
| **Filter By Restrictions** | Off = full catalog; On = weapon/form/env filter |
| **Is Evil Skill Path** | Align with AnimatedModifier |
| **Skill Catalog Level** | Align with AnimatedModifier |
| **Log Panel Anime Scene** | **LogPanel** component |
### LogPanel (`LogPanelAnimeScene`)
| Field | Assign |
|---|---|
| **Copy Text Button Prefab** | `CopyTextButton` row |
| **Copy Text Buttons Parent** | Layout parent for rows |
Filled automatically when you click a skill on SkillPanel.
---
## How to test a skill animation
### 1. Enter Play Mode
1. Open `Assets/PerfectWorld/Scene/AnimationTest.unity`.
2. Press **Play**.
3. Filter Console: `[AnimSceneBootstrap]`.
Expected logs: element data ready → `SetPlayerModel` done → `CECHostSkillModel initialized``[SkillTriggerPanel] Refreshed: N buttons added`.
### 2. Character, weapon, camera
- **Role:** AnimatedModifier **Initial Role**, or Play Mode **Switch model** on AnimatedModifier.
- **Weapon:** set **Active Weapon Action Type Index** and prefabs in **Weapon By Action Type**; **Re-apply active weapon slot** in Play Mode if you change the index.
- **Camera:** **NextView** / **PreviosView** to step through **Camera Poses**.
Skill clip names depend on weapon suffix (`{prefix}_{weapon_suffix}_吟唱_`, `_施放起_`, `_施放落_`).
### 3. Skill list filter (optional)
On SkillPanel, **Filter By Restrictions**:
- **Off** — full profession catalog (bootstrap default after load).
- **On** — only skills passing weapon/form/move-env (MP/AP faked unlimited).
Context menu: **Debug: Refresh From Skill Model**, **Debug: Inject All Config Skills**.
### 4. Target marker
Place **Target Marker** (`CECMonsterTest`) ~5 units in front of the player for non-self skills. Self-target skills use the host id.
### 5. Click a skill (SkillPanel)
`LocalCastSkill` does the following:
1. **LogPanel**`Reset()`, skill **ID**, then GFX rows:
- **Cast** — from cast combined action
- **Attack** — rise/fall combined actions
- **Fly** / **Hit** / **HitGrnd** — composer or `ElementSkill.GetAllGFX`
2. **Cast animation**`PlaySkillCastAction(skillId)` immediately.
3. **Attack animation** — after ~**1 s**, `CECAttacksMan.AddSkillAttack` + `PlaySkillAttackAction`.
Click a LogPanel row to copy the GFX basename (green = Addressables key exists, red = missing).
### 6. Raw actions (optional)
AnimatedModifier Play Mode inspector: **Stand (0)**, **Run (3)**, or custom action index + **Play action** (not full skill chains).
---
## VFX note (commented composer path)
In `SkillTriggerPanel.LocalCastSkill`, the direct **`composerMan.Play(...)`** block is **commented out**. VFX in this scene is driven mainly by:
- Combined-action GFX events logged on **LogPanel**
- The **delayed** `AddSkillAttack` / `PlaySkillAttackAction` path (attack event + `CECAttacksMan` tick)
You may see **animations** without all **fly/hit GFX** playing until those events run. Re-enabling `composerMan.Play` would be a separate local-VFX experiment; the current workflow matches “animation-first” debugging.
---
## Data flow
```mermaid
sequenceDiagram
participant User
participant SkillPanel
participant LogPanel
participant Host as CECHostPlayer
participant Attacks as CECAttacksMan
User->>SkillPanel: Click skill button
SkillPanel->>LogPanel: Reset + cast/attack/fly/hit GFX rows
SkillPanel->>Host: PlaySkillCastAction(skillId)
Note over SkillPanel: Wait ~1s
SkillPanel->>Attacks: AddSkillAttack(...)
SkillPanel->>Host: PlaySkillAttackAction(skillId, ...)
```
---
## Troubleshooting
| Symptom | Check |
|---|---|
| No model | `NPCManager`, Addressables, `[AnimSceneBootstrap]`; **Player** on AnimatedModifier |
| No skill motion | **Bind Player Visual After Model Load**; Animancer + `CombinedActionSO` on `.ecm` |
| `PlaySkillCastAction returned false` | Skill not in action map; wrong weapon suffix |
| Empty skill grid | Wait for bootstrap; **Inject All Config Skills**; evil/god path vs profession |
| GFX at origin | **Target Marker** assigned and positioned |
| LogPanel all red | Register GFX in Addressables (`gfx/...`) |
| Camera buttons dead | **NextView** / **PreviosView** wired to `ChangeNextCamera` / `ChangePreviosCamera` on AnimatedModifier |
**Console:** `[AnimSceneBootstrap]`, `[SkillTriggerPanel]`
---
## Script references
- `Assets/PerfectWorld/Scripts/AnimTestScene/AnimScenePlayerBootstrap.cs`
- `Assets/PerfectWorld/Scripts/AnimTestScene/LogPanelAnimeScene.cs`
- `Assets/PerfectWorld/Scripts/Debug/SkillTriggerPanel.cs`
- `Assets/PerfectWorld/Scripts/Editor/AnimScenePlayerBootstrapEditor.cs`