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;