修复内容:

PlayerMovement:新增 _facingLocked 字段 + LockFacing(bool) 方法;UpdateFacing() 锁定时直接返回
WallSlideState:OnStateEnter 调用 LockFacing(true) + FlipFacing(_wallDir);OnStateExit 调用 LockFacing(false) 解锁
WallJumpState:OnStateEnter 保险性再调一次 LockFacing(false);WallJumpAway/Toward 同步写入 _inputVelocityX,确保解锁后 UpdateFacing 朝向正确(背墙跳 = 离墙方向,对墙跳 = 朝墙方向)
This commit is contained in:
2026-05-22 10:48:52 +08:00
parent 285ac46e31
commit 68d4c699ae
15 changed files with 235 additions and 418 deletions

View File

@@ -775,9 +775,13 @@ namespace BaseGames.Editor
{
var report = new List<string>();
GameObject go = new GameObject("MovingPlatform");
Undo.RegisterCreatedObjectUndo(go, "Place Moving Platform");
go.transform.position = GetDropPosition();
// 根节点:平台实体 + 路径点都挂在此节点下,路径点不随平台本体移动
GameObject root = new GameObject("MovingPlatform_Root");
Undo.RegisterCreatedObjectUndo(root, "Place Moving Platform");
root.transform.position = GetDropPosition();
// 平台实体:作为 root 子节点
GameObject go = GetOrCreateChild(root.transform, "MovingPlatform").gameObject;
SetLayer(go, "Platform", report);
Rigidbody2D rb = GetOrAddComponent<Rigidbody2D>(go);
@@ -796,22 +800,23 @@ namespace BaseGames.Editor
sensorCol.size = new Vector2(3.8f, 0.25f);
sensorCol.offset = new Vector2(0f, 0.33f);
// Waypoint markers (LinearAB mode end points)
Transform wpA = GetOrCreateChild(go.transform, "WaypointA");
Transform wpB = GetOrCreateChild(go.transform, "WaypointB");
wpA.localPosition = new Vector3(-3f, 0f, 0f);
wpB.localPosition = new Vector3(3f, 0f, 0f);
// 路径点:挂在 root 下而非平台下,平台移动时路径点位置不变
Transform wpA = GetOrCreateChild(root.transform, "WaypointA");
Transform wpB = GetOrCreateChild(root.transform, "WaypointB");
wpA.position = root.transform.position + new Vector3(-3f, 0f, 0f);
wpB.position = root.transform.position + new Vector3( 3f, 0f, 0f);
MovingPlatform platform = GetOrAddComponent<MovingPlatform>(go);
AssignReference(platform, "_passengerSensor", sensorCol, report);
AssignLayerMask(platform, "_passengerLayer", new[] { "Player", "Enemy" }, report);
AssignObjectArray(platform, "_wayPoints", new Object[] { wpA, wpB }, report);
report.Add("WaypointA / WaypointB 为移动端点,可将其拖出平台并在场景中调整位置。");
report.Add("WaypointA / WaypointB 已挂在 MovingPlatform_Root 下(非平台子节点),平台移动时路径点保持原位。");
report.Add("在场景中调整 WaypointA / WaypointB 的世界位置即可设置移动端点。");
report.Add("如需触发激活,改 _moveType = TriggeredLinear 并将 VoidEventChannelSO 拖入 _activationChannel。");
Selection.activeGameObject = go;
MarkDirtyAndLog("Moving Platform", go, report);
Selection.activeGameObject = root;
MarkDirtyAndLog("Moving Platform", root, report);
}
[MenuItem("BaseGames/Scene/Place/Tilemap Ground", priority = 160)]