Spine 4.2 Physics - General Questions
@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.
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?
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.
No gravity still happening in 4.2.14-beta and 4.2.15-beta editor and spine-unity-4.2-2024-02-15-beta
vs Unity
minimum test case with 2 bones, 1 with and 1 without a physics constraint with gravity at 100, brand new spine made with latest beta editor
vs unity in play mode showing no gravity (brand new empty project), just using a Skeleton Animation dragged into scene
Sent this test project along with the test spine to the contact mail. Please take a look.
We've fixed this in 4.2.24-beta by adding a reference scale
field to skeletons. It's fixed in spine-libgdx and will be ported to spine-unity and the other runtimes soon, likely Monday (tomorrow).
Thanks for your help identifying this issue!
@bantam We've just published the bugfix of the above issue for the spine-unity 4.2-beta runtime as well (and spine-csharp in general).
A new spine-unity 4.2-beta unitypackage is available for download here as usual:
https://esotericsoftware.com/spine-unity-download#spine-unity-4.2-beta
Thanks for reporting this issue!
I gave it a test with the latest editor and package and gravity works now!! Thank you! This is such a great feature sincerely.
I noticed one issue, I think the issue is in editor not unity. Take the physics bone from last spine, nested split it into 4 bones, give it a quick mesh and weight it like normal and apply physics constraint to every bone with default settings and 100 gravity. In editor it curls around ignoring gravity or like it's doing something related to the parent bone.
(can't seem to upload images to the forum so I will put them on dropbox)
In unity I feel it does what you expect coming to a natural rest to gravity
I've put the images demonstrating this along the new test spine with the mesh and bones to test this issue in the dropbox link also in case it helps!
https://www.dropbox.com/scl/fo/b6yctecqdac6no38hqnzi/h?rlkey=g2jytges7qjfw1ge4u7z9vnpe&dl=0
Thanks for the project file. I tried this in 4.2.25-beta:
- Export to JSON.
Import Data
, 0.1 scale.
The result is correct:
The imported skeleton has the expected reference scale of 10 (normally 100).
If I checked the wrong thing, please let me know what are the reproduction steps!
We'll look into the forum not allowing uploads, I see it too.
Thanks for responding. The issue is that spine editor and Unity implement this differently. 100 gravity on all 4 bones in unity flops down towards gravity in an expected way (check the Unity png in the dropbox link). In the editor it curls away from gravity. If it's correct in editor then it really needs to behave the same way in Unity so animators can rely on it working reasonably similar to how it behaves in editor. Otherwise they will have to load up unity every time to adjust the gravity to look right which in my experience they are most averse to leaving editor.
I added Flop Difference Unity.zip to the dropbox so you can see the gravity difference in Unity
Assets/Scenes/test.unity
https://www.dropbox.com/scl/fo/b6yctecqdac6no38hqnzi/h?rlkey=g2jytges7qjfw1ge4u7z9vnpe&dl=0