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

This commit is contained in:
Harald Csaszar 2020-05-07 15:07:26 +02:00
parent 6a317a1e3f
commit 3e93e2daf1
2 changed files with 15 additions and 0 deletions

View File

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

View File

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