多轮审查和修复
This commit is contained in:
@@ -48,6 +48,17 @@ namespace BaseGames.Enemies.Navigation
|
||||
{
|
||||
if (_movement != null) _movement.movementSpeed = speed;
|
||||
}
|
||||
|
||||
public bool IsNearEdge()
|
||||
{
|
||||
// 双射线检测:脚下前方是否有地面
|
||||
if (_navAgent == null) return false;
|
||||
var origin = (Vector2)transform.position;
|
||||
var facing = transform.localScale.x >= 0f ? Vector2.right : Vector2.left;
|
||||
var groundMask = ~0; // 检测所有层;可收窄至 Ground 层
|
||||
bool groundAhead = Physics2D.Raycast(origin + facing * 0.3f, Vector2.down, 0.5f, groundMask);
|
||||
return !groundAhead;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user