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; }