From 9b9f57871aecdb0fe770048577805c14ffc2c854 Mon Sep 17 00:00:00 2001 From: Danil Iarosh Date: Fri, 3 Jul 2026 16:58:27 +0300 Subject: [PATCH] Mirror visualRoot hierarchy in Screen Wrapping container to fix clone rotation and scale flipping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Подробный список изменений: - В JumpPlayerController.cs добавлено поле visualRootClone для создания промежуточного объекта-зеркала. - В RebuildWrapVisuals все клоны спрайтов теперь создаются дочерними к visualRootClone. - В CopyWrappedVisuals локальная позиция, поворот и масштаб оригинального visualRoot копируются в visualRootClone, а клоны спрайтов позиционируются локально. Это решило проблему переворота персонажа вверх ногами при отзеркаливании скейлом. --- .../Runtime/Gameplay/JumpPlayerController.cs | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/Runtime/Gameplay/JumpPlayerController.cs b/Assets/Scripts/Runtime/Gameplay/JumpPlayerController.cs index 02aaf17..1f44aa1 100644 --- a/Assets/Scripts/Runtime/Gameplay/JumpPlayerController.cs +++ b/Assets/Scripts/Runtime/Gameplay/JumpPlayerController.cs @@ -80,6 +80,7 @@ namespace DanroJump.Gameplay private bool moveActionWasEnabled; #endif private Transform wrapVisualCloneRoot; + private Transform visualRootClone; private readonly List sourceRenderers = new(); private readonly List wrapRendererClones = new(); private readonly List landingHandlerBuffer = new(); @@ -1597,6 +1598,12 @@ namespace DanroJump.Gameplay wrapVisualCloneRoot.gameObject.SetActive(false); } + if (visualRootClone == null) + { + visualRootClone = new GameObject("VisualRoot Clone").transform; + visualRootClone.SetParent(wrapVisualCloneRoot, false); + } + var allRenderers = visualRoot != null ? visualRoot.GetComponentsInChildren(true) : GetComponentsInChildren(true); @@ -1624,7 +1631,7 @@ namespace DanroJump.Gameplay } var clone = new GameObject($"{sourceRenderer.name} Wrap Clone").AddComponent(); - clone.transform.SetParent(wrapVisualCloneRoot, false); + clone.transform.SetParent(visualRootClone, false); wrapRendererClones.Insert(0, clone); } @@ -1723,7 +1730,14 @@ namespace DanroJump.Gameplay { if (wrapVisualCloneRoot != null) { - wrapVisualCloneRoot.localPosition = Vector3.zero; + wrapVisualCloneRoot.localPosition = offset; + } + + if (visualRoot != null && visualRootClone != null) + { + visualRootClone.localPosition = visualRoot.localPosition; + visualRootClone.localRotation = visualRoot.localRotation; + visualRootClone.localScale = visualRoot.localScale; } for (var index = 0; index < sourceRenderers.Count; index++) @@ -1755,8 +1769,8 @@ namespace DanroJump.Gameplay clone.sortingLayerID = source.sortingLayerID; clone.sortingOrder = source.sortingOrder; clone.sharedMaterial = source.sharedMaterial; - clone.transform.position = source.transform.position + offset; - clone.transform.rotation = source.transform.rotation; + clone.transform.localPosition = source.transform.localPosition; + clone.transform.localRotation = source.transform.localRotation; clone.transform.localScale = source.transform.localScale; clone.gameObject.layer = source.gameObject.layer; }