Commit Graph
31 Commits
Author SHA1 Message Date
joywayer 3c622a69f2 refactor(enemy): NavLinkType 迁入 INavLinkHandler 并改述为能力驱动的地形穿越;补交新脚本 .meta 2026-07-28 11:50:17 +08:00
joywayer 4455062ee9 refactor(editor): 脚手架改用 GroundNavigator,移除寻路库引用与导航面放置工具 2026-07-28 11:45:24 +08:00
joywayer 219fe46719 fix(enemy): GroundNavigator 停止改为直写移动输入,消除与 EnemyBase.StopMovement 的无限递归(栈溢出) 2026-07-28 11:39:25 +08:00
joywayer de3c9deff4 refactor(enemy): 消费者切换到 IEnemyNavigator(Wander/Waypoints 去导航图化,调试面板简化) 2026-07-28 11:25:21 +08:00
joywayer 49627d357d refactor(enemy): FlyingDirectNavigator 改名 FlyingNavigator 并切换到 IEnemyNavigator 2026-07-28 11:17:34 +08:00
joywayer 668bc3500e feat(enemy): 新增 GroundNavigator 地面直接移动导航(+7 纯函数单测)
补充 EditMode 测试程序集对 BaseGames.Enemies.Navigation 的引用(此前缺失,新测试无法编译)
2026-07-28 11:12:11 +08:00
joywayer c929b5efb7 refactor(enemy): 三处卡死检测收敛为 StallDetector;修复 Pace 持续受阻时无法掉头的死锁 2026-07-28 11:04:18 +08:00
joywayer 297f9d2968 feat(enemy): IEnemyLocomotion 增加 Pursue 寻路逼近原语(RunSpeed) 2026-07-24 12:23:43 +08:00
joywayer 4a80a11ab5 fix(enemy): 改道到最近可达点时同步防抖记账,避免下次 RequestMoveTo 被误吞 2026-07-23 17:22:11 +08:00
joywayer 8e71b1a922 feat(enemy): Waypoints 受阻/到达即结算推进,删除对不可达点的无限重发 2026-07-23 17:09:06 +08:00
joywayer 72ed14428c feat(enemy): FlyingDirectNavigator 实现受阻/最近可达点成员(飞行单位恒 false) 2026-07-23 17:06:21 +08:00
joywayer 675e1950af feat(enemy): EnemyNavAgent 卡死检测+统一受阻处理+best-effort 改道到最近可达点 2026-07-23 16:56:56 +08:00
joywayerandClaude Opus 4.8 16edf7cb90 fix(enemy): Waypoint 巡逻寻路失败/丢失时自动重发,修复出生即巡逻卡死
TickPatrol 原来只在"首次或到达路点"时发一次 MoveTo。若这一次 UpdatePath 失败(如敌人
刚出生、当帧尚未映射到 NavGraph),路径永不建立且再不重试 → 永久原地不动(mode=Patrol
但 IsFollowingAPath=False)。旧 Entry=Idle_Disguise 因巡逻只在出生很久后才开始而掩盖了此问题。

新增:有目标但 nav 空闲(!IsMoving)且未到达 → 重发同一目标(只重发不推进索引;RequestMoveTo
自带 0.25s 防抖,寻路跨帧计算期间的重发被吞掉,不会每帧重启寻路)。

Play 实测:出生即在两路点间以 WalkSpeed 正常往返巡逻。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 15:13:19 +08:00
joywayerandClaude Opus 4.8 00ee48f750 feat(enemy): EnemyLocomotion 运行时巡逻调试(Inspector 面板 + Scene Gizmos)
排查"敌人原地不动"用:PlayMode 下自定义 Inspector 实时显示 模式/策略/是否移动/是否在导航图上/
当前路点与吸附目标/到目标距离vs到达半径/目标是否可达,并按优先级给出定位诊断(模式非Patrol|不在
NavGraph|吸附失败|不可达|已寻路未动)。Scene 视图 Gizmos 画出全部路点连线 + 当前吸附目标(绿/红)+到达半径。

EnemyLocomotion 加 #if UNITY_EDITOR 只读调试访问器 + OnDrawGizmosSelected;记录 _wpResolveOk。
Editor 程序集补 BaseGames.AI 引用(PatrolStrategy/LocomotionMode 所在)。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 11:57:02 +08:00
joywayerandClaude Opus 4.8 66d100f353 fix(enemy): 目标点吸附改用固定大搜索距离,与 PB2d 映射任意点机制一致
上版把搜索距离绑到 agent→目标距离(仿 UpdatePath),仍脆弱:吸附距离取决于 agent 离得多远
而非目标离导航段多远——agent 贴在高处路点正下方时距离小、reach 小仍会漏。

查明 PB2d 映射机制(NavGraph.TryMapPointSurface):queryAABB 边长=传入值、可靠搜索半径仅其一半;
PB2d 映射"鼠标点击等任意点"用固定的 closestToSegmentMaxDistance(默认 20,"想多大就多大")。
据此改为:EnemyNavAgent._maxSnapDistance(默认 10m,真实"点离最近段"上限),底层传 2× 补偿 AABB 半宽。
只要目标在 _maxSnapDistance 内一定吸附到最近烘焙段,返回 false 仅表示目标真正脱离导航面。

Play 实测:两路点 + 压力用例(agent 正上方 3m/5m)ResolveStandablePoint 均 ok=True 且映射到地面段。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 10:35:24 +08:00
joywayerandClaude Opus 4.8 4ecf949d83 fix(enemy): 目标点吸附改用距离自适应搜索,修复稍离地路点吸附失败
之前 TryGetStandablePointNear 用固定 2m 搜索半径(实为 ±1m AABB)+ agent 过滤映射,
导致摆放在离地面 >1m 的路点(如 wp y=3.16 而地面段 y=2.00)映射失败、误报"超出搜索半径"。

改为与 PB2d 自身 UpdatePath 映射目标完全一致:搜索距离=agent 到目标距离(+0.1),
用不带 agent 过滤的 TryMapPoint(就近段几何映射,可达性交给 allowCloseEnoughPath 寻路阶段)。
只要图上有段就一定吸附得到最近点。移除 EnemyNavAgent._goalMapSearchRadius 固定半径字段。

Play 实测:两个路点 ResolveStandablePoint 均 ok=True((-20.90,3.16)->(-20.90,2.00)),
CanReach=True,敌人实际走到 x=-20.75(目标 -20.90)后停,无 EnemyLocomotion 报警。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 10:10:35 +08:00
joywayerandClaude Opus 4.8 132cd24908 feat(enemy): 目标点吸附统一处理导航宽度,Waypoint 不再卡崖边
将"角色导航宽度"收口到导航执行层单一入口,意图层(Locomotion/AI)只递原始目标、不再感知身体尺寸:

- NavAgent 新增 TryGetStandablePointNear:把世界点映射到最近可行走段并按 endMargin 内缩两端(与 SetRandomDestinationOnCurrentSegment 同源)
- EnemyNavAgent 新增 ResolveStandablePoint,以 EnemyMovement.EdgeSafeMargin(半宽+落崖余量)为唯一宽度真源;加 _goalMapSearchRadius
- IPathAgent 暴露 ResolveStandablePoint;FlyingDirectNavigator 原样返回(飞行无崖沿约束),NullPathAgent 空实现
- EnemyLocomotion Waypoint 分支改用吸附后的可达点做移动与到达判定,修复路点摆在空中/崖外时永不到达而卡死;吸附失败显式报错暴露误配,不静默兜底

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 15:52:18 +08:00
joywayerandClaude Opus 4.8 7f7d237915 feat(enemy): Wander 到达随机点后可配置停顿时长
到达一个段内随机游走点后原地停顿 [_wanderPauseMin, _wanderPauseMax] 秒再挑下一个点:
- 两个可配置字段(相等=固定时长;都为 0=不停顿立即挑点),每次停顿时长在区间内随机
- 停顿期间切 Idle 步态(否则站着播 Walk=原地踏步),速度归零
- 切换 locomotion 模式时清停顿态,避免残留
实测:移动→到点→停顿(Idle,velX=0)→再出发 循环正常。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 13:45:21 +08:00
joywayerandClaude Opus 4.8 31b77fa473 feat(enemy): Wander 巡逻改为当前段内随机 + 按身体宽度内缩两端
修复地面单位 Wander 巡逻"走一小段就停":
- 随机点从全图(GetRandomPointOnGraph)改为限定在 agent 当前所站的 NavSegment 上,
  不再跨越跳/落/拐角 NavLink,避免路径跨沟被崖边夹停或卡在过不去的 link。
- 段内随机 t 按"身体前缘安全余量(碰撞体半宽 + 悬崖检测前向偏移)"从两端各内缩,
  避免随机点落在角色宽度站不住的崖沿(WouldFallAhead 夹停、IsFollowingAPath 不复位→卡死)。
- NavAgent.SetRandomDestinationOnCurrentSegment(endMargin):段内采样+内缩(段过短退化到中点)
- EnemyMovement.EdgeSafeMargin:身体前缘安全余量
- IPathAgent.WalkToRandomOnSegment():EnemyNavAgent 传入 margin;飞行单位复用局部偏移;Null 返回 false

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 12:45:01 +08:00
joywayer 36aa2006e4 @
feat(enemy): E001 追击动画 Skill_Start/Loop/End 完整化,符合设计文档

依据 Docs/Game/Design/小怪设计-程序开发文档-01.md:感知→Skill_Start(张口,单次)
→Skill_Loop(快速爬行追击,循环)→丢失目标→Skill_End(收招,单次)→Move_Patrol,
E001 无警觉态。

原问题:ContactChaseAbility 的 loop/end clip 都空、无 start clip,追击全程无
动画;Approach 步态还错播 Move;有多余警觉态(Alert clip 也空)。

- ContactChaseAbility:加 _startClip;协程 Skill_Start(锁动画+等时长,不伤人)→
  开伤害+Approach+Skill_Loop(循环)→退出播 Skill_End。丢失目标(ExternalRequest
  中断)播 Skill_End;受击/死亡硬打断不播。
- EnemyBase:加动画锁 LockAnim/IsAnimLocked——一次性招式动画期间步态不覆盖;
  PlayLocomotionClip 的 Approach 改为不驱动步态(追击动画归能力)。
- EnemyLocomotion:锁定期不算"已应用",解锁后重同步步态(避免卡在 Skill_End)。
- ENM_E001_Stats:HasAlertState=false(设计无警觉态)。
- prefab + 脚手架:ContactChaseAbility 接线 Skill_Start/Loop/End;新增
  AssignClipTransition 助手(按名+路径定位同名 clip)。

PlayMode 验证:Skill_Start(locked/不伤人)→Skill_Loop(伤害开)→Skill_End
(locked)→步态恢复 Move,全链符合设计。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@
2026-07-10 16:27:02 +08:00
joywayer a4b9729de7 @
fix(enemy): 巡逻边缘不越界 + 卡死兜底 + Locomotion 惰性发现

- WouldBlockAhead(EnemyMovement):按请求方向从碰撞体前缘(bounds.max/min.x)
  即时射线判墙/悬崖,天然考虑碰撞体宽度;MoveHorizontal 据此夹紧前进,保证
  "碰撞体边缘停在地形边缘、不越界"。移动层夹紧与 Pace 翻向共用同一判定,
  避免"夹停却不掉头"。nav 走 MoveWithSpeed 不受影响。
- Pace 加窗口净位移卡死兜底:撞上未挂检测层的墙/卡角(含贴墙微抖)也能翻向,
  用净位移而非逐帧差以免微抖重置计数。
- EnemyBase.Locomotion 改惰性发现:关域重载下 Awake 设的实例字段可能残留
  为 null,首次访问按需补发现,编辑器/构建都不为空(此前致入口态偶发 NRE)。

PlayMode(跨调用取样,避免 Thread.Sleep 冻结主线程)验证:Pace 来回踱步、
遇边缘/墙掉头、碰撞体不越界。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@
2026-07-10 15:12:28 +08:00
joywayer 6f52e4ff81 @
fix(enemy): Pace 巡逻改边沿触发翻向,修边缘左右抖动

TickPatrol 跑在 Update(可变帧率),IsWallAhead/IsLedgeAhead 在 FixedUpdate
刷新。原电平触发(每帧 blocked 就翻向)会在检测刷新前的多个 Update 帧把同一
障碍连翻多次→掉头边缘左右抖动几次才正常。改为边沿触发(仅障碍首次出现时翻
一次),用 _paceBlockedPrev 记录上帧状态。PlayMode 验证:踱步移动正常、无
连续快速翻转。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@
2026-07-10 14:36:53 +08:00
joywayerandClaude Opus 4.8 6a34b42db0 fix(enemy): 终审修复——删死代码群体警戒、修 Waypoints 到达推进、补 Locomotion 缺失报错
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-10 14:05:56 +08:00
joywayerandClaude Opus 4.8 c43ca8e8b6 feat(enemy): EnemyLocomotion 巡逻策略 Pace(踱步) + Waypoints(路点 loop/ping-pong)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-10 13:47:14 +08:00
joywayerandClaude Opus 4.8 347d0e2f50 feat(enemy): EnemyLocomotion 按模式驱动步态动画(Idle/Walk/Alert/Run)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-10 13:33:16 +08:00
joywayerandClaude Opus 4.8 0f988c4cef feat(enemy): 新增 EnemyLocomotion 执行器(Idle/Patrol-Wander/Face/Approach)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-10 11:59:02 +08:00
joywayerandClaude Opus 4.8 490329e1dc refactor(nav): 敌人移动改为物理原生架构——根治 TBM 与 Dynamic 刚体冲突
根因: NavAgent.Position setter 直接写 transform.position, TBM 段移动每帧写它, 与敌人
Dynamic 刚体(重力/碰撞)冲突(旧代码靠"NavDriving清零velocity"缓解,但对Dynamic刚体直接
写transform.position本就不推荐,易卡墙/穿透/被物理覆盖)。

根本解: 寻路降为"顾问"(只给方向),移动执行归物理:
- EnemyNavAgent.Awake 禁用 TBM.SegmentMovement(不再写 transform.position);
- FixedUpdate 改物理原生桥: 朝 PathSubGoal 写 MoveDir+MoveSpeed 由 EnemyMovement 施加
  velocity+重力执行, 到达子目标时 CompleteSegmentTraversal 推进段(原由TBM负责);
- EnemyMovement 撤掉 NavDriving 的清零velocity/只朝向门, nav方向统一走velocity移动。
保留击退/击飞/落地等全部物理反馈。

附带修 PerceptionStateMachine: 追击维持改"追逐区 OR 视野区"任一(视野los可能被墙挡漏检,
仅靠视野会导致玩家在近身追逐区内却Chase↔Patrol抖动、nav被反复Stop不移动)。

PlayMode 验证: 敌人 nav 巡逻/追击均用velocity移动(FollowPath/onSeg=True)、追击稳定无抖动。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 17:19:01 +08:00
joywayerandClaude Opus 4.8 643f63c737 fix(nav): 修复 nav 寻路核心用法——重寻路防抖 + allowCloseEnoughPath
根因1: PathBerserker2d NavAgent.UpdatePath 明确禁止每帧调用(路径计算跨帧,每帧重启则永不完成、
agent永不移动),而追击每帧 MoveTo→RequestMoveTo→UpdatePath。修: EnemyNavAgent.RequestMoveTo
加防抖(目标位移阈值0.5m + 最小间隔0.25s),让路径算完并跟随;StopNavigation 复位。
根因2: NavAgent.allowCloseEnoughPath 默认false→追击玩家(常不在导航段上)寻路直接失败。
修: 脚手架(4个PlaceExxx)+E001 prefab 设为 true(寻路到最近可达点)。
验证: 敌人 nav 巡逻/追击已能真正跟随路径移动(following=True)。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 16:43:52 +08:00
joywayer 06048c966a feat: Add HurtBoxOwnerGuard to prevent multiple damage registrations from the same HitBox activation
- Implemented HurtBoxOwnerGuard to ensure that multiple HurtBoxes on the same character do not register damage multiple times during a single HitBox activation.
- Added custom editor for HitBox to facilitate the creation of shape colliders with HitBoxColliderProxy.
- Introduced PhysicsPerceptionSystem for enemy perception, supporting multiple detection modes including RangeCircle, BatchLOS, FanCast, and BoxCast.
- Created EnemyPatrolZone to define patrol and chase areas for enemies, allowing for shared zones among multiple enemies.
- Added BD_IsOutsideZone conditional task for Behavior Designer to check if an enemy or player is outside a defined patrol zone.
2026-06-02 16:10:44 +08:00
joywayer a1b4e629aa feat: Implement Room Streaming System
- Add RoomStreamingManager to manage room loading and unloading based on player proximity.
- Create StreamingBudgetConfigSO for memory and performance budgeting of the streaming system.
- Introduce TransitionDirector to handle seamless and atmospheric fade transitions between rooms.
- Develop WorldGraph to represent room connectivity and facilitate neighbor queries and distance calculations.
- Implement RoomNode and RoomEdge classes to structure room data and connections.
2026-05-23 19:10:29 +08:00
joywayer f264329751 摄像机区域的架构改动 2026-05-15 14:47:24 +08:00