• RuntimesUnity
  • Spine 4.2 Physics - General Questions

Yes, posts can only be edited for 10-15 minutes after posting.

Physics is affected by bone lengths. It sounds like there is a bug where data loading scale is not being applied in a way that results in the same physics behavior at different scales. We'll take a closer look at it and get back to you!

    Related Discussions
    ...

    Nate Heya Nate, thanks for the info/answer! Sounds good, if you guys happen to need any additional info just let me know.

    7 أيام لاحقا

    Harald Hey Harald!

    I updated with that version, and unfortunately it didn't fix the issue. I just emailed a zip of my Spine project to contact@esotericsoftware.com. In the project there are a couple different pieces, since I was testing things out. The issue happens with this bone, which is the only one that uses the physics constraint for "Translate X/Y". When I set that physics constraint for Translate X/Y back to 0, it fixes the issue.

    The issue is that, in Unity, the bone goes way out to the side, something like 200x further than it should in the animation.

    To repro:
    1) Export/import the project into spine
    2) Create new SkeletonAnimation by dragging the SkeletonData asset into the scene
    3) Set the SkeletonAnimation to use the animation called "wind animated"
    4) Run the scene and observe that the bone goes way further to the right than it does when you play the "wind animated" animation in Spine.

    As mentioned above, changing the "scale" on the SkeletonData asset itself (the one that is by default 0.01) seemed to affect it, so I'm wondering if its some sort of conversion from Spine units to Unity units, or something like that 🤔

    Thanks for checking it out and let me know if I can provide any more info or anything!

    Oh dear, sorry to hear that the issue persists! Thanks for the repro project, we'll reply here on the forum as soon as we've figured out what's going wrong.

    @Jamez0r We have just pushed a bugfix to the 4.2-beta repo, it turned out that load scale (import scale in Unity) was ignored, affecting wind and gravity. A new spine-unity 4.2-beta unitypackage is available for download:
    https://esotericsoftware.com/spine-unity-download
    Please let us know if this now fixes the issues on your end as well. Thanks again for reporting!

    Issue ticket for later reference:
    EsotericSoftware/spine-runtimes2446

      Harald Woohoo! That fixed all of the issues we had that were physics-related. Thanks!

      There is only one more issue that we're experiencing with 4.2, which I wasn't sure if it was related to that physics-issue you just fixed or not so I hadn't mentioned it.

      The problem is with an IK constraint for this Woodsman character's elbow. We've used rigs like this before, so we think its an issue specifically with 4.2. I just sent you a zip of the spine project (I replied to the email response you sent me earlier today). There is an animation called responses/technique/default/4.release. This animation has the character's claw-arm raise upward, and at a certain point when he is raising it up, an IK constraint on his arm is keyed to go from "Options: Positive: True" to "Options: Positive: False" (the checkbox).

      In Spine, this looks as intended.

      In Unity, the arm's elbow flips out, almost as though the "Options: Positive" value is being toggled every frame (just a guess, thats kind of what it looks like)

      I took the original responses/technique/default/4.release animation and deleted all of the keys except the ones for that claw-arm and named it responses/technique/default/4.release (ARM ONLY - IK ISSUE) to make it easier to see the issue.

      Steps to repro: Export the project from Spine to Unity, create a new SkeletonAnimation with it, and set its default animation to the responses/technique/default/4.release (ARM ONLY - IK ISSUE) animation. Observe that the elbow goes wild during the animation.

      Unity version 2022.3.12f1
      Spine-Unity Runtime: Package version: spine-unity-4.2-2024-01-11-beta.unitypackage

      • It seems like the issue happens during the time period in the animation when the IK: Arm_Right_IK is set to Option: Positive: False, which starts on frame 3 of the animation.

      Let me know if I can provide any more info, or if you want me to start a separate thread or submit an official bug report or anything. This is the only remaining issue we're having with 4.2, so we're pretty stoked!

      @Jamez0r Glad to hear the updated fixed your physics-related issues, thanks for the feedback!

      Sorry to hear that another issue remains, thanks for the reproduction project. We'll have a look at it and get back to you here on the forum as always. Thanks for reporting!

      @Jamez0r We've just pushed a bugfix to the 4.2-beta branch. A new 4.2-beta unitypackage has just been released:
      https://esotericsoftware.com/spine-unity-download
      We hope that this now fixes all issues you encountered with 4.2-beta 8). Thanks again for reporting!

      Issue ticket for later reference:
      EsotericSoftware/spine-runtimes2448

        Harald Its working!!

        Thanks Harald, you rock! Now to play around with all the physics stuff some more 🙂

        Quick question just to point me in the right direction here - in regards to question #2 on my original post in this thread, is there a way to programmatically set the (global) wind/gravity values for a SkeletonAnimation? I might mess around with testing out that wind system I mentioned sometime soon 😃

        Everything is possible programmatically. 🙂

        You can just set the wind and gravity values on the physics constraints directly. If you key the physics constraints' wind and gravity, you'd need to modify the values after you apply animations.

        If you would rather use an animation, you'd have to create a new animation and timelines or dig through an existing animation's timelines to find the wind and gravity timelines, then you can change the keyed values, add/delete keys, etc on the wind and gravity timelines. Note that by default the animations are shared by all skeleton instances, so you'd need to duplicate the animation if you don't want your changes to affect other skeleton instances.

          Nate Hey Nate, thanks for the info!

          What I'm looking to try out is not having wind or gravity keyed in any animation on the character, but instead having my own weather system in Unity determine "how windy it should be" each frame at the location each spine-character is standing, and then apply that value to the SkeletonAnimation somehow. Imagine a grassy field with characters sprinkled around in it, and my weather system handles calculating the "wind value" for each character as gusts of wind blow across the field.

          If I knew "at this moment in time, the wind value for this character at this location should be 2.5", how could I most easily apply that to the SkeletonAnimation for that character? You mentioned being able to set the wind/gravity values on the physics constraints directly, so would that be the best to do it? Meaning I need to aggregate a list of the physics constraints, and iterate through them applying the wind value (rather than doing it at some "global" level that automatically affects all of them)?

          Thanks for the info!

          Yep, just set all the physics constraints' wind and gravity. Super easy!

          There is no "global" setting. The global timelines just set the value for multiple constraints.

            Nate Thanks Nate!

            Would like to use physics constraints' wind and gravity programmatically in the future. My head is still wrapped around trying have Spine-Cpp and Godot-Gdscript play nice 😑.

            I think we've been experiencing something similar, we're using todays update which fixed some other issues we had but we're suffering a leaning issue that differs between Spine and Unity much like this

            100 gravity on the right shoulder strap in Unity at the end of the Angry animation

            100 gravity on the right shoulder strap in Spine editor at the end of the Angry animation

            0 gravity in Spine Editor, the right shoulder strap veers further to the left much like in the Unity scene

            I've sent the spine file and a blank unity project with just this scene and spine already configured to show the issue to contact@esotericsoftware.com, just hit play in the unity project and you'll see the difference.

            Edit: just noticed the clip accessory on the weapon is also exhibiting this if that helps!

            @bantam Sorry to hear you've encountered problems, thanks for reporting! This sounds like the bug with wind and gravity which has been fixed just 4 days ago:
            EsotericSoftware/spine-runtimes2446 (via this commit)
            Could you please have a try whether the very latest spine-unity package resolves the issue on your end?

              Harald

              Thanks for responding, I may have I have missed a step to make it work, do we need to programmatically provide a gravity level in Unity somewhere? I didn't see a method for it through the SkeletonAnimation api.

              Downloaded and run with spine-unity 4.2-beta (updated 2024-01-12), if it's not this version please let me know I will test again. I think it is correct though as I see the changes in the source.

              I added a couple of break points to see if it hits those changes and it does, it seems to be applying gravity to the data structure.

              Seems to make it to PhysicsConstraint.cs constructor

              makes it down here

              Also tried it with another one of our spines that uses 100 gravity for hair with a test pose to make it more obvious, 2023 blank project with default unity settings with SkeletonAnimation pulled into an otherwise blank scene to make sure its not any of our current projects settings screwing things up.

              Hair not applying gravity

              100 Gravity hair successfully working in Spine Editor

              These gravities are set up in the setup pose in editor not in the animation timeline if that helps.

              P.S. these physics constraints have really been impressive! It's a game changer for our productivity.

                • تم التحرير

                @bantam Apologies if the issue was not fixed with the latest package! We will have a look at it right away.

                bantam I may have I have missed a step to make it work, do we need to programmatically provide a gravity level in Unity somewhere?

                No setup is required on the Unity side, the gravity settings are in skeleton-space and should work regardless of your Unity setup.

                bantam P.S. these physics constraints have really been impressive! It's a game changer for our productivity.

                Very glad to hear, thanks!

                We've fixed this in 4.2.10-beta! It is correct at runtime.