To prevent your character from stretching due to physics constraints when moving it, you can try setting the Mix
value of the physics constraints to 0
during the movement. This effectively disables the physics constraints temporarily. Once the movement is complete, you can set the Mix
value back to its original state to re-enable the physics constraints. This approach should prevent any unwanted stretching or movement when re-enabling the SkeletonAnimation
.
Here's a code snippet to illustrate this approach:
// Disable physics constraints
foreach (var constraint in skeletonAnimation.skeleton.Constraints) {
if (constraint is Spine.PhysicsConstraint physicsConstraint) {
physicsConstraint.Mix = 0;
}
}
// Move your character here
// Re-enable physics constraints
foreach (var constraint in skeletonAnimation.skeleton.Constraints) {
if (constraint is Spine.PhysicsConstraint physicsConstraint) {
physicsConstraint.Mix = 1; // or the original mix value
}
}
This method allows you to control the physics constraints directly without disabling the entire SkeletonAnimation
component.