Mirror visualRoot hierarchy in Screen Wrapping container to fix clone rotation and scale flipping
Подробный список изменений: - В JumpPlayerController.cs добавлено поле visualRootClone для создания промежуточного объекта-зеркала. - В RebuildWrapVisuals все клоны спрайтов теперь создаются дочерними к visualRootClone. - В CopyWrappedVisuals локальная позиция, поворот и масштаб оригинального visualRoot копируются в visualRootClone, а клоны спрайтов позиционируются локально. Это решило проблему переворота персонажа вверх ногами при отзеркаливании скейлом.
This commit is contained in:
parent
4e8c258824
commit
9b9f57871a
@ -80,6 +80,7 @@ namespace DanroJump.Gameplay
|
||||
private bool moveActionWasEnabled;
|
||||
#endif
|
||||
private Transform wrapVisualCloneRoot;
|
||||
private Transform visualRootClone;
|
||||
private readonly List<SpriteRenderer> sourceRenderers = new();
|
||||
private readonly List<SpriteRenderer> wrapRendererClones = new();
|
||||
private readonly List<IPlatformLandingHandler> 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<SpriteRenderer>(true)
|
||||
: GetComponentsInChildren<SpriteRenderer>(true);
|
||||
@ -1624,7 +1631,7 @@ namespace DanroJump.Gameplay
|
||||
}
|
||||
|
||||
var clone = new GameObject($"{sourceRenderer.name} Wrap Clone").AddComponent<SpriteRenderer>();
|
||||
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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user