fix(ai): E001 追击真正移动+攻击——直接水平爬行 + prefab 补挂 EnemyAiBrain
追击移动从 A* 寻路(MoveTo)改为直接朝玩家水平爬行(MoveInDirectionWithSpeed): 地面爬行怪不需寻路,且不依赖场景 NavGraph 烘焙(PathBerserker2d 在测试场景失效)。 ENM_CaoZhi prefab 补挂 EnemyAiBrain(_definitionId=E001),使对象池/prefab 生成的敌人也有AI (此前只有脚手架场景实例有brain)。PlayMode 验证:敌人爬向玩家并接触伤害击杀。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -29,10 +29,13 @@ namespace BaseGames.Enemies.Abilities
|
||||
if (_contactDamage != null)
|
||||
_contactDamage.enabled = true;
|
||||
|
||||
// 追击直到玩家消失或被 AI 中断(退出追击的决策归 AI,见 EnemyBrainContext.InterruptAbilities)
|
||||
// 追击直到玩家消失或被 AI 中断(退出追击的决策归 AI,见 EnemyBrainContext.InterruptAbilities)。
|
||||
// 地面爬行怪用直接水平爬行追击(朝玩家方向),不依赖 A* 寻路。
|
||||
float runSpeed = _enemy.Stats != null ? _enemy.Stats.RunSpeed : 0f;
|
||||
while (_enemy.PlayerTransform != null)
|
||||
{
|
||||
_enemy.MoveTo(_enemy.PlayerTransform.position);
|
||||
float dir = _enemy.PlayerTransform.position.x >= _enemy.transform.position.x ? 1f : -1f;
|
||||
_enemy.MoveInDirectionWithSpeed(dir, runSpeed);
|
||||
yield return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user