[unity] Fixed physics constraints ignoring Z movement when Y-rotated. Closes #2614.

This commit is contained in:
Harald Csaszar 2024-08-28 15:21:36 +02:00
parent 4e5e47d375
commit 4fe9e4582d
2 changed files with 5 additions and 5 deletions

View File

@ -303,7 +303,7 @@ namespace Spine.Unity {
[SerializeField] protected Transform physicsMovementRelativeTo = null; [SerializeField] protected Transform physicsMovementRelativeTo = null;
/// <summary>Used for applying Transform translation to skeleton PhysicsConstraints.</summary> /// <summary>Used for applying Transform translation to skeleton PhysicsConstraints.</summary>
protected Vector2 lastPosition; protected Vector3 lastPosition;
/// <summary>Used for applying Transform rotation to skeleton PhysicsConstraints.</summary> /// <summary>Used for applying Transform rotation to skeleton PhysicsConstraints.</summary>
protected float lastRotation; protected float lastRotation;
@ -520,8 +520,8 @@ namespace Spine.Unity {
public virtual void ApplyTransformMovementToPhysics () { public virtual void ApplyTransformMovementToPhysics () {
if (Application.isPlaying) { if (Application.isPlaying) {
if (physicsPositionInheritanceFactor != Vector2.zero) { if (physicsPositionInheritanceFactor != Vector2.zero) {
Vector2 position = GetPhysicsTransformPosition(); Vector3 position = GetPhysicsTransformPosition();
Vector2 positionDelta = position - lastPosition; Vector3 positionDelta = position - lastPosition;
positionDelta = transform.InverseTransformVector(positionDelta); positionDelta = transform.InverseTransformVector(positionDelta);
if (physicsMovementRelativeTo != null) { if (physicsMovementRelativeTo != null) {
@ -541,7 +541,7 @@ namespace Spine.Unity {
} }
} }
protected Vector2 GetPhysicsTransformPosition () { protected Vector3 GetPhysicsTransformPosition () {
if (physicsMovementRelativeTo == null) { if (physicsMovementRelativeTo == null) {
return transform.position; return transform.position;
} else { } else {

View File

@ -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.80", "version": "4.2.81",
"unity": "2018.3", "unity": "2018.3",
"author": { "author": {
"name": "Esoteric Software", "name": "Esoteric Software",