fix(enemy): 终审修复——删死代码群体警戒、修 Waypoints 到达推进、补 Locomotion 缺失报错
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -17,6 +17,7 @@ namespace BaseGames.Enemies
|
||||
[Header("Waypoints 策略参数")]
|
||||
[SerializeField] private Transform[] _waypoints;
|
||||
[SerializeField] private bool _pingPong;
|
||||
[SerializeField] private float _waypointArriveRadius = 0.4f;
|
||||
|
||||
private EnemyBase _enemy;
|
||||
private LocomotionMode _mode = LocomotionMode.Idle;
|
||||
@@ -116,7 +117,7 @@ namespace BaseGames.Enemies
|
||||
_enemy.MoveInDirection(_paceDir);
|
||||
break;
|
||||
|
||||
case PatrolStrategy.Waypoints: // 按序(loop 或 ping-pong)巡逻路点
|
||||
case PatrolStrategy.Waypoints:
|
||||
if (_waypoints == null || _waypoints.Length == 0)
|
||||
{
|
||||
if (!_warnedNoWaypoints)
|
||||
@@ -126,7 +127,10 @@ namespace BaseGames.Enemies
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (_enemy.Nav != null && !_enemy.Nav.IsMoving)
|
||||
// 仅首次或"已到达当前路点"时推进并寻路——不依赖 IsMoving
|
||||
// (PathBerserker2d 寻路跨帧异步,IsMoving 在寻路计算期间为 false,会误触发每帧推进)。
|
||||
if (_wpIndex < 0 ||
|
||||
Vector2.Distance(_enemy.transform.position, _waypoints[_wpIndex].position) <= _waypointArriveRadius)
|
||||
{
|
||||
AdvanceWaypoint();
|
||||
_enemy.MoveTo(_waypoints[_wpIndex].position);
|
||||
|
||||
Reference in New Issue
Block a user