This commit is contained in:
2026-05-19 13:54:52 +08:00
parent 15df36659a
commit 750baeb219

View File

@@ -20,9 +20,6 @@ namespace BaseGames.Player
[SerializeField] private Vector2 _groundCheckSize = new Vector2(0.8f, 0.05f); [SerializeField] private Vector2 _groundCheckSize = new Vector2(0.8f, 0.05f);
[SerializeField] private LayerMask _groundLayer; [SerializeField] private LayerMask _groundLayer;
[Header("朝向")]
[SerializeField] private SpriteRenderer _spriteRenderer;
// ── 运行时状态 ──────────────────────────────────────────────────────── // ── 运行时状态 ────────────────────────────────────────────────────────
private Rigidbody2D _rb; private Rigidbody2D _rb;
private float _coyoteTimer; private float _coyoteTimer;
@@ -74,8 +71,6 @@ namespace BaseGames.Player
// SpritePixelSnapperLateUpdate +1000在插值结果基础上吸附到像素网格 // SpritePixelSnapperLateUpdate +1000在插值结果基础上吸附到像素网格
// 与 CameraPixelSnapper 同格对齐,消除亚像素模糊;停止时 ≤2 帧像素追赶不可感知。 // 与 CameraPixelSnapper 同格对齐,消除亚像素模糊;停止时 ≤2 帧像素追赶不可感知。
_rb.interpolation = RigidbodyInterpolation2D.Interpolate; _rb.interpolation = RigidbodyInterpolation2D.Interpolate;
if (_spriteRenderer == null)
_spriteRenderer = GetComponentInChildren<SpriteRenderer>();
} }
private void FixedUpdate() private void FixedUpdate()
@@ -179,8 +174,9 @@ namespace BaseGames.Player
int dir = vx > 0f ? 1 : -1; int dir = vx > 0f ? 1 : -1;
if (dir == _facingDirection) return; if (dir == _facingDirection) return;
_facingDirection = dir; _facingDirection = dir;
if (_spriteRenderer != null) // 翻转整个 Transform而非仅 SpriteRenderer.flipX
_spriteRenderer.flipX = dir < 0; // 确保 WeaponSocket / SkillSocket 等所有子节点的 HitBox 及投射物生成点随朝向镜像。
transform.localScale = new Vector3(dir, 1f, 1f);
} }
// ── 取消窗口 ────────────────────────────────────────────────────────── // ── 取消窗口 ──────────────────────────────────────────────────────────