• RuntimesUnity
  • Moving an object stopping the physical restrictions

Hello, guys!

I'm trying to find a way to move a character. First, I need to disable the physical restrictions to avoid stretching the character when moving it.

I tried with stopping all: skeletonAnimation.enabled = false;

It worked, more or less, because, effectively, the object doesn't stretch when I move it, but once I activate it again (skeletonAnimation.enabled = true), the character moves a little.

I posted a video with the example: https://mega.nz/file/MwVlWDaY#c6COVVn2CTRGQBU_sQLqXJDze6muOB04aRUDwKzfjvc

Related Discussions
...

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.

Sorry, I didn't find this post before. I searched for this problem on the forum, but I didn't find it earlier. This post solved my problem, even without the need to use code:
https://es.esotericsoftware.com/forum/d/26948-stop-spine-physical-via-script--%E5%A6%82%E4%BD%95%E7%94%A8%E7%A8%8B%E5%BC%8F%E5%81%9C%E6%AD%A2%E7%89%A9%E7%90%86%E7%B4%84%E6%9D%9F

I used the first method Harald mentioned, and it worked perfectly!

1) In the Inspector of SkeletonAnimation under the Advanced Physics Inheritance section set Movement relative to to a new parent GameObject which you want to move freely around without causing physics movement.

Very glad to hear, thanks for taking the time to reply!