From 3e93e2daf1a651adf41415ed7919855d8a276f2d Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Thu, 7 May 2020 15:07:26 +0200 Subject: [PATCH] [unity] Fixed ghost-movement of Ragdoll components: They did not update the RagdollParent transform. Activate correct behaviour by disabling the inspector property `Old Ragdoll Behaviour` which was introduced to automatically be backwards-compatible. Closes #1670. --- .../SkeletonUtility Modules/SkeletonRagdoll.cs | 7 +++++++ .../SkeletonUtility Modules/SkeletonRagdoll2D.cs | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonRagdoll.cs b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonRagdoll.cs index 2cefa8747c..6f7750ccd3 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonRagdoll.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonRagdoll.cs @@ -68,6 +68,7 @@ public class SkeletonRagdoll : MonoBehaviour { public int colliderLayer = 0; [Range(0, 1)] public float mix = 1; + public bool oldRagdollBehaviour = true; #endregion ISkeletonAnimation targetSkeletonComponent; @@ -322,6 +323,12 @@ public class SkeletonRagdoll : MonoBehaviour { var t = pair.Value; bool isStartingBone = b == StartingBone; Transform parentTransform = isStartingBone ? ragdollRoot : boneTable[b.Parent]; + if (!oldRagdollBehaviour && isStartingBone) { + if (b != skeleton.RootBone) { // RagdollRoot is not skeleton root. + ragdollRoot.localPosition = new Vector3(b.Parent.WorldX, b.Parent.WorldY, 0); + ragdollRoot.localRotation = Quaternion.Euler(0, 0, GetPropagatedRotation(b.Parent)); + } + } Vector3 parentTransformWorldPosition = parentTransform.position; Quaternion parentTransformWorldRotation = parentTransform.rotation; diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonRagdoll2D.cs b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonRagdoll2D.cs index daf23bc298..cad12b8bcd 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonRagdoll2D.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonRagdoll2D.cs @@ -71,6 +71,7 @@ public class SkeletonRagdoll2D : MonoBehaviour { public int colliderLayer = 0; [Range(0, 1)] public float mix = 1; + public bool oldRagdollBehaviour = true; #endregion ISkeletonAnimation targetSkeletonComponent; @@ -338,6 +339,13 @@ public class SkeletonRagdoll2D : MonoBehaviour { var t = pair.Value; bool isStartingBone = (b == startingBone); Transform parentTransform = isStartingBone ? ragdollRoot : boneTable[b.Parent]; + if (!oldRagdollBehaviour && isStartingBone) { + if (b != skeleton.RootBone) { // RagdollRoot is not skeleton root. + ragdollRoot.localPosition = new Vector3(b.Parent.WorldX, b.Parent.WorldY, 0); + ragdollRoot.localRotation = Quaternion.Euler(0, 0, GetPropagatedRotation(b.Parent)); + } + } + Vector3 parentTransformWorldPosition = parentTransform.position; Quaternion parentTransformWorldRotation = parentTransform.rotation;