diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs index 246e38171..ac5994eb3 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs @@ -572,13 +572,25 @@ namespace Spine.Unity { /// When enabled, Transform rotation is applied to skeleton PhysicsConstraints. public bool applyRotationToPhysics = true; /// Reference transform relative to which physics movement will be calculated, or null to use world location. - public Transform physicsMovementRelativeTo = null; + [SerializeField] protected Transform physicsMovementRelativeTo = null; /// Used for applying Transform translation to skeleton PhysicsConstraints. protected Vector2 lastPosition; /// Used for applying Transform rotation to skeleton PhysicsConstraints. protected float lastRotation; + /// Reference transform relative to which physics movement will be calculated, or null to use world location. + public Transform PhysicsMovementRelativeTo { + get { + return physicsMovementRelativeTo; + } + set { + physicsMovementRelativeTo = value; + if (applyTranslationToPhysics) ResetLastPosition(); + if (applyRotationToPhysics) ResetLastRotation(); + } + } + public void ResetLastPosition () { lastPosition = GetPhysicsTransformPosition(); } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs index 51cebc816..a07f2cde4 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs @@ -294,13 +294,25 @@ namespace Spine.Unity { /// When enabled, Transform rotation is applied to skeleton PhysicsConstraints. public bool applyRotationToPhysics = true; /// Reference transform relative to which physics movement will be calculated, or null to use world location. - public Transform physicsMovementRelativeTo = null; + [SerializeField] protected Transform physicsMovementRelativeTo = null; /// Used for applying Transform translation to skeleton PhysicsConstraints. protected Vector2 lastPosition; /// Used for applying Transform rotation to skeleton PhysicsConstraints. protected float lastRotation; + /// Reference transform relative to which physics movement will be calculated, or null to use world location. + public Transform PhysicsMovementRelativeTo { + get { + return physicsMovementRelativeTo; + } + set { + physicsMovementRelativeTo = value; + if (applyTranslationToPhysics) ResetLastPosition(); + if (applyRotationToPhysics) ResetLastRotation(); + } + } + public void ResetLastPosition () { lastPosition = GetPhysicsTransformPosition(); }