Преглед на файлове

[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.

Harald Csaszar преди 5 години
родител
ревизия
3e93e2daf1

+ 7 - 0
spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonRagdoll.cs

@@ -68,6 +68,7 @@ namespace Spine.Unity.Examples {
 		public int colliderLayer = 0;
 		[Range(0, 1)]
 		public float mix = 1;
+		public bool oldRagdollBehaviour = true;
 		#endregion
 
 		ISkeletonAnimation targetSkeletonComponent;
@@ -322,6 +323,12 @@ namespace Spine.Unity.Examples {
 				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;
 

+ 8 - 0
spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonRagdoll2D.cs

@@ -71,6 +71,7 @@ namespace Spine.Unity.Examples {
 		public int colliderLayer = 0;
 		[Range(0, 1)]
 		public float mix = 1;
+		public bool oldRagdollBehaviour = true;
 		#endregion
 
 		ISkeletonAnimation targetSkeletonComponent;
@@ -338,6 +339,13 @@ namespace Spine.Unity.Examples {
 				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;