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:
@@ -173,6 +173,7 @@ GameObject:
|
||||
- component: {fileID: 47111425058439551}
|
||||
- component: {fileID: 8798631432003224959}
|
||||
- component: {fileID: 3225188436228842581}
|
||||
- component: {fileID: 8800423420238451973}
|
||||
m_Layer: 13
|
||||
m_Name: ENM_CaoZhi
|
||||
m_TagString: Untagged
|
||||
@@ -500,6 +501,19 @@ MonoBehaviour:
|
||||
obstructLayer:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
--- !u!114 &8800423420238451973
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4060394683168505230}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d92d657c6bbdfe246a7333e04f79f8f7, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_definitionId: E001
|
||||
--- !u!1 &6141681234124103774
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -564,7 +578,6 @@ MonoBehaviour:
|
||||
_Clip: {fileID: 0}
|
||||
_NormalizedStartTime: NaN
|
||||
_contactDamage: {fileID: 9135205194319985817}
|
||||
_aggroSlotName: aggro
|
||||
references:
|
||||
version: 2
|
||||
RefIds: []
|
||||
|
||||
@@ -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