Skip to content

Commit

Permalink
[unity] Fixed ghost-movement of Ragdoll components: They did not upda…
Browse files Browse the repository at this point in the history
…te the RagdollParent transform. Activate correct behaviour by disabling the inspector property `Old Ragdoll Behaviour` which was introduced to automatically be backwards-compatible. Closes #1670.
  • Loading branch information
HaraldCsaszar committed May 7, 2020
1 parent 6a317a1 commit 3e93e2d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 3e93e2d

Please sign in to comment.