@
fix(enemy): 转身中不再静默丢弃新朝向请求,修"冲刺方向与朝向相反" UpdateFacing 原 `if (_isTurning) return` 会把转身进行中的新朝向请求静默丢弃。 当敌人在平台边缘触发 Pace 翻转(开始 Flip 转身)同时进入追击时,追击的 FaceDirection(朝玩家)被丢弃,旧的巡逻转身完成后朝向定格在与玩家相反方向 → 冲刺朝玩家方向移动、脸却朝相反(并连带"冲刺中途转身""提前停"两个衍生现象)。 改为:转身中收到不同方向请求时重定向(停旧转身按新方向重起),同向则忽略。 根因修复,惠及 Pace/追击/FaceTarget 所有调用方。 systematic-debugging 确定性复现证实:修复前 AFTER-TURN dir=+1 facing=-1; 修复后开阔地冲刺全程 dir=1 facing=1、冲满 6 米到真实平台边缘才停。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> @
This commit is contained in:
@@ -507,8 +507,19 @@ namespace BaseGames.Enemies
|
|||||||
private void UpdateFacing(float dir)
|
private void UpdateFacing(float dir)
|
||||||
{
|
{
|
||||||
if (Mathf.Approximately(dir, 0f)) return;
|
if (Mathf.Approximately(dir, 0f)) return;
|
||||||
if (_isTurning) return; // 转身进行中,忽略新的朝向请求
|
|
||||||
int newDir = dir > 0f ? 1 : -1;
|
int newDir = dir > 0f ? 1 : -1;
|
||||||
|
|
||||||
|
// 转身进行中:与当前转身目标同向 → 忽略;不同向 → 重定向(停旧转身重起),
|
||||||
|
// 不能静默丢弃——否则新意图(如追击朝玩家)被进行中的旧转身(如巡逻边缘翻转)覆盖,
|
||||||
|
// 造成"朝向与移动方向相反"。(根因修复,惠及 Pace/追击/FaceTarget 所有调用方。)
|
||||||
|
if (_isTurning)
|
||||||
|
{
|
||||||
|
if (newDir == _pendingFacingDir) return;
|
||||||
|
if (_turnCoroutine != null) StopCoroutine(_turnCoroutine);
|
||||||
|
_turnCoroutine = null;
|
||||||
|
_isTurning = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (newDir == _facingDir) return;
|
if (newDir == _facingDir) return;
|
||||||
|
|
||||||
if (_enableTurnAnimation && _animancer != null && _animConfig?.Turn != null)
|
if (_enableTurnAnimation && _animancer != null && _animConfig?.Turn != null)
|
||||||
|
|||||||
Reference in New Issue
Block a user