Project_WL/AgentScripts/WL762_ClipMotion.cs

101 lines
6.2 KiB
C#
Raw Normal View History

WL 리뉴얼 세션 2026-09-06~07 (#760~#800) — 전투·배경·UI·타격감 (조직 PD 로그 #746~#800 · 대화로그 §14~§24) - 전투: Knight@Attack1~3_S 3콤보(4 컨트롤러·클래스별 서브클립) · 타겟팅 4규칙(정면 우선·재타겟·즉시 공격·어그로 금지 · WLTargetingSettings) · 대쉬 후 공격(Stander@Chase_Start · DashDriver · 5 m · 사정거리+0.8 · 근거리 적 우선) · 공격 이동 FrameTable(발 접지 실측 표 · AttackRootMotion) · 충돌 반경/투사체 0.3 배(WLCollisionTuning) · 무적(임시)·펫 금지(WLGameplaySettings) - 검기: NamuFX Slash_B 배리언트 Effect_WLSwingArc 원 피팅 정합 배치 + 캘리브레이션(SlashArcMeasure · SlashTrailSettings) · 찌르기 Effect_WLStab 대기 · 램프 리본(BladeTrail · WL_BladeRibbon.shader · T_WL_BladeRibbonRamp) 보존(drawRibbon 0) - 타격감: Assets/WL/Feel(WLHitFeel · 히트스톱 0.03 · 셰이크 0.10 m · 몹 펀치 1.12 · Actor.Get_Damage 훅 1줄 · 원본 RealCamera 셰이크 결함 대체) - 배경/맵: LMHPOLY Demo_01~10 → WL_Nature01~10(프리팹·씬·NavMesh·스포너·BattleMapConfig) · 물(ToonWaterU) · 포스트 블룸 0.9/0.3 · 잔디(BruteForce·드레싱) 제거 · 마젠타 머티리얼 URP 변환 - UI: 세로 HUD(WL_HUD · 하단 5메뉴 폭 전체 · 채팅/전투 패드 숨김 · WLIngameUiOverride) · Title/TitleInfo 1080×1920 Expand + 배경 높이 fit(WLBackgroundFit) · 로딩 SortOrder_5(WLRawImageAspectSync · 초점표 8장) · Loading1~8 ASTC 6×6 - 도구: AgentScripts/*(LightProbe · WL_MapSwitch · WL760~WL800 프로브/집행/검증 · 상단 사용법 주석) · 에디터 락 프로토콜 파일(staging) - 제외(별도 커밋 예정): Assets/LMHPOLY(703 MB) · Assets/Feel(422 MB) · Assets/Shinabro(300 MB) — 에셋 스토어/구 WL 팩 원본 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-06 23:24:25 +00:00
// WL762_ClipMotion.cs — PD 지시 #762 실측 도구 (에디트 모드 · Assets 무수정)
// unity command run_script --file AgentScripts/WL762_ClipMotion.cs --entry WL762_ClipMotion.MeasureAll
// unity command run_script --file AgentScripts/WL762_ClipMotion.cs --entry WL762_ClipMotion.Measure --args '["Assets/Res_Addr/Animations/Animation/Paladin/attack.FBX", "Sword&Shield_Attack1"]'
// 🔴 PM 실측(2026-09-06): Humanoid 클립을 아바타 없는 FBX 인스턴스에 SampleAnimationClip 하면 전부 0 이 나온다(리타게팅 불가).
// → 이 버전은 **PC 프리팹(Ai01 · Animator + Humanoid Avatar)** 에 샘플링하고 `HumanBodyBones.Hips` 본을 읽는다.
// 그래도 0 이면(AnimationMode 가 Humanoid 를 지원하지 않는 경우) Play 중 `WL760_Seq` 류로 골반 본 위치를 프레임마다 기록해 실측할 것.
// 목적: "위치는 그대로인데 모션이 크다" 의 크기(골반의 캐릭터-전방 이동량)를 수치로 잡는다.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEngine;
public static class WL762_ClipMotion
{
const string PcPrefab = "Assets/Res_Addr/PC/Ai01.prefab";
public static object MeasureAll()
{
var sb = new StringBuilder();
var targets = new[]
{
new[] { "Assets/Res_Addr/Animations/Animation/Paladin/attack.FBX", "Sword&Shield_Attack1" },
new[] { "Assets/Res_Addr/Animations/Animation/Paladin/Stander@Sword&Shield_Attack2.FBX", "Sword&Shield_Attack2" },
new[] { "Assets/Res_Addr/Animations/Animation/Paladin/Stander@Sword&Shield_Attack3.FBX", "Sword&Shield_Attack3" },
new[] { "Assets/Res_Addr/Animations/Animation/OneHand/Knight@Attack1_S.FBX", "Attack1" },
new[] { "Assets/Res_Addr/Animations/Animation/OneHand/Knight@Attack2_S.FBX", "Attack2" },
new[] { "Assets/Res_Addr/Animations/Animation/OneHand/Knight@Attack3_S.FBX", "Attack3" },
};
foreach (var t in targets) sb.AppendLine(Measure(t[0], t[1]).ToString());
return sb.ToString();
}
public static object Measure(string fbxPath, string clipName)
{
var all = AssetDatabase.LoadAllAssetsAtPath(fbxPath);
var clip = all.OfType<AnimationClip>().FirstOrDefault(c => c.name == clipName && !c.name.StartsWith("__preview__"));
if (clip == null) return "clip not found: " + clipName + " in " + fbxPath + " (clips: " + string.Join(",", all.OfType<AnimationClip>().Select(c => c.name)) + ")";
var pcPrefab = AssetDatabase.LoadAssetAtPath<GameObject>(PcPrefab);
if (pcPrefab == null) return "PC prefab not found " + PcPrefab;
var go = (GameObject)UnityEngine.Object.Instantiate(pcPrefab);
go.hideFlags = HideFlags.HideAndDontSave;
go.transform.position = Vector3.zero; go.transform.rotation = Quaternion.identity;
var animator = go.GetComponentInChildren<Animator>();
if (animator == null) { UnityEngine.Object.DestroyImmediate(go); return "PC prefab has no Animator"; }
var animGo = animator.gameObject;
var hips = animator.isHuman ? animator.GetBoneTransform(HumanBodyBones.Hips) : null;
var lfoot = animator.isHuman ? animator.GetBoneTransform(HumanBodyBones.LeftFoot) : null;
var sb = new StringBuilder();
var importer = AssetImporter.GetAtPath(fbxPath) as ModelImporter;
string rm = "?";
if (importer != null)
{
var ca = importer.clipAnimations.FirstOrDefault(c => c.name == clipName);
if (ca != null) rm = "bakeXZ=" + ca.lockRootPositionXZ + " bakeY=" + ca.lockRootHeightY + " bakeRot=" + ca.lockRootRotation + " keepOrigXZ=" + ca.keepOriginalPositionXZ;
rm += " animType=" + importer.animationType;
}
sb.AppendLine("== " + clipName + " len=" + clip.length.ToString("F3") + "s hasRootCurves=" + clip.hasRootCurves + " hasMotionCurves=" + clip.hasMotionCurves + " humanMotion=" + clip.humanMotion
+ " " + rm + " sampledOn=" + animGo.name + " isHuman=" + animator.isHuman + " avatar=" + (animator.avatar != null ? animator.avatar.name : "null") + " hips=" + (hips != null ? hips.name : "?"));
if (hips == null) { UnityEngine.Object.DestroyImmediate(go); sb.AppendLine(" (no humanoid hips — cannot sample)"); return sb.ToString(); }
AnimationMode.StartAnimationMode();
try
{
AnimationMode.BeginSampling();
AnimationMode.SampleAnimationClip(animGo, clip, 0f);
AnimationMode.EndSampling();
Vector3 root0 = animGo.transform.position; Vector3 hip0 = hips.position; Vector3 foot0 = lfoot != null ? lfoot.position : Vector3.zero;
float maxHipZ = 0f, minHipZ = 0f, tMax = 0f, maxHipX = 0f;
var rows = new List<string>();
int n = 12;
for (int i = 0; i <= n; i++)
{
float t = clip.length * i / n;
AnimationMode.BeginSampling();
AnimationMode.SampleAnimationClip(animGo, clip, t);
AnimationMode.EndSampling();
Vector3 dr = animGo.transform.position - root0;
Vector3 dh = hips.position - hip0;
Vector3 df = lfoot != null ? lfoot.position - foot0 : Vector3.zero;
if (dh.z > maxHipZ) { maxHipZ = dh.z; tMax = t; }
if (dh.z < minHipZ) minHipZ = dh.z;
if (Mathf.Abs(dh.x) > Mathf.Abs(maxHipX)) maxHipX = dh.x;
rows.Add(" t=" + t.ToString("F2") + " root(z)=" + dr.z.ToString("F3") + " hips(dx,dy,dz)=(" + dh.x.ToString("F2") + "," + dh.y.ToString("F2") + "," + dh.z.ToString("F2") + ")"
+ " lfoot(dz)=" + df.z.ToString("F2"));
}
foreach (var r in rows) sb.AppendLine(r);
sb.AppendLine(" => hips forward travel: max +" + maxHipZ.ToString("F2") + " m at t=" + tMax.ToString("F2") + "s, min " + minHipZ.ToString("F2") + " m, lateral max " + maxHipX.ToString("F2") + " m, model scale=" + animGo.transform.lossyScale.x.ToString("F2"));
}
finally
{
AnimationMode.StopAnimationMode();
UnityEngine.Object.DestroyImmediate(go);
}
return sb.ToString();
}
}