[unity] Fixed physics inheritance ignoring transform rotation. Closes #2538.

This commit is contained in:
Harald Csaszar 2024-05-31 18:09:59 +02:00
parent 63dc7d1bb8
commit 96797adeb5
3 changed files with 12 additions and 9 deletions

View File

@ -400,12 +400,13 @@ namespace Spine.Unity {
if (physicsPositionInheritanceFactor != Vector2.zero) {
Vector2 position = GetPhysicsTransformPosition();
Vector2 positionDelta = (position - lastPosition) / meshScale;
positionDelta = transform.InverseTransformVector(positionDelta);
if (physicsMovementRelativeTo != null) {
positionDelta.x *= physicsMovementRelativeTo.lossyScale.x;
positionDelta.y *= physicsMovementRelativeTo.lossyScale.y;
positionDelta = physicsMovementRelativeTo.TransformVector(positionDelta);
}
positionDelta.x *= physicsPositionInheritanceFactor.x / transform.lossyScale.x;
positionDelta.y *= physicsPositionInheritanceFactor.y / transform.lossyScale.y;
positionDelta.x *= physicsPositionInheritanceFactor.x;
positionDelta.y *= physicsPositionInheritanceFactor.y;
skeleton.PhysicsTranslate(positionDelta.x, positionDelta.y);
lastPosition = position;

View File

@ -522,12 +522,14 @@ namespace Spine.Unity {
if (physicsPositionInheritanceFactor != Vector2.zero) {
Vector2 position = GetPhysicsTransformPosition();
Vector2 positionDelta = position - lastPosition;
positionDelta = transform.InverseTransformVector(positionDelta);
if (physicsMovementRelativeTo != null) {
positionDelta.x *= physicsMovementRelativeTo.lossyScale.x;
positionDelta.y *= physicsMovementRelativeTo.lossyScale.y;
positionDelta = physicsMovementRelativeTo.TransformVector(positionDelta);
}
positionDelta.x *= physicsPositionInheritanceFactor.x / transform.lossyScale.x;
positionDelta.y *= physicsPositionInheritanceFactor.y / transform.lossyScale.y;
positionDelta.x *= physicsPositionInheritanceFactor.x;
positionDelta.y *= physicsPositionInheritanceFactor.y;
skeleton.PhysicsTranslate(positionDelta.x, positionDelta.y);
lastPosition = position;
}

View File

@ -2,7 +2,7 @@
"name": "com.esotericsoftware.spine.spine-unity",
"displayName": "spine-unity Runtime",
"description": "This plugin provides the spine-unity runtime core.",
"version": "4.2.66",
"version": "4.2.67",
"unity": "2018.3",
"author": {
"name": "Esoteric Software",