mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-02 21:59:09 +08:00
[unity] Fixed physics inheritance ignoring transform rotation. Closes #2538.
This commit is contained in:
parent
63dc7d1bb8
commit
96797adeb5
@ -400,12 +400,13 @@ namespace Spine.Unity {
|
|||||||
if (physicsPositionInheritanceFactor != Vector2.zero) {
|
if (physicsPositionInheritanceFactor != Vector2.zero) {
|
||||||
Vector2 position = GetPhysicsTransformPosition();
|
Vector2 position = GetPhysicsTransformPosition();
|
||||||
Vector2 positionDelta = (position - lastPosition) / meshScale;
|
Vector2 positionDelta = (position - lastPosition) / meshScale;
|
||||||
|
|
||||||
|
positionDelta = transform.InverseTransformVector(positionDelta);
|
||||||
if (physicsMovementRelativeTo != null) {
|
if (physicsMovementRelativeTo != null) {
|
||||||
positionDelta.x *= physicsMovementRelativeTo.lossyScale.x;
|
positionDelta = physicsMovementRelativeTo.TransformVector(positionDelta);
|
||||||
positionDelta.y *= physicsMovementRelativeTo.lossyScale.y;
|
|
||||||
}
|
}
|
||||||
positionDelta.x *= physicsPositionInheritanceFactor.x / transform.lossyScale.x;
|
positionDelta.x *= physicsPositionInheritanceFactor.x;
|
||||||
positionDelta.y *= physicsPositionInheritanceFactor.y / transform.lossyScale.y;
|
positionDelta.y *= physicsPositionInheritanceFactor.y;
|
||||||
|
|
||||||
skeleton.PhysicsTranslate(positionDelta.x, positionDelta.y);
|
skeleton.PhysicsTranslate(positionDelta.x, positionDelta.y);
|
||||||
lastPosition = position;
|
lastPosition = position;
|
||||||
|
|||||||
@ -522,12 +522,14 @@ namespace Spine.Unity {
|
|||||||
if (physicsPositionInheritanceFactor != Vector2.zero) {
|
if (physicsPositionInheritanceFactor != Vector2.zero) {
|
||||||
Vector2 position = GetPhysicsTransformPosition();
|
Vector2 position = GetPhysicsTransformPosition();
|
||||||
Vector2 positionDelta = position - lastPosition;
|
Vector2 positionDelta = position - lastPosition;
|
||||||
|
|
||||||
|
positionDelta = transform.InverseTransformVector(positionDelta);
|
||||||
if (physicsMovementRelativeTo != null) {
|
if (physicsMovementRelativeTo != null) {
|
||||||
positionDelta.x *= physicsMovementRelativeTo.lossyScale.x;
|
positionDelta = physicsMovementRelativeTo.TransformVector(positionDelta);
|
||||||
positionDelta.y *= physicsMovementRelativeTo.lossyScale.y;
|
|
||||||
}
|
}
|
||||||
positionDelta.x *= physicsPositionInheritanceFactor.x / transform.lossyScale.x;
|
positionDelta.x *= physicsPositionInheritanceFactor.x;
|
||||||
positionDelta.y *= physicsPositionInheritanceFactor.y / transform.lossyScale.y;
|
positionDelta.y *= physicsPositionInheritanceFactor.y;
|
||||||
|
|
||||||
skeleton.PhysicsTranslate(positionDelta.x, positionDelta.y);
|
skeleton.PhysicsTranslate(positionDelta.x, positionDelta.y);
|
||||||
lastPosition = position;
|
lastPosition = position;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
"name": "com.esotericsoftware.spine.spine-unity",
|
"name": "com.esotericsoftware.spine.spine-unity",
|
||||||
"displayName": "spine-unity Runtime",
|
"displayName": "spine-unity Runtime",
|
||||||
"description": "This plugin provides the spine-unity runtime core.",
|
"description": "This plugin provides the spine-unity runtime core.",
|
||||||
"version": "4.2.66",
|
"version": "4.2.67",
|
||||||
"unity": "2018.3",
|
"unity": "2018.3",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Esoteric Software",
|
"name": "Esoteric Software",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user