Jamez0r

I have a character that has a lot of "cloth strips" that I'm using the 2D Chain Bones for. Most of the time it looks great (I'm using the physics chain bones for a lot of things - banners, a "weeping willow" tree, etc, its awesome!), but there are a couple times where the chain "freaks out" and I can't figure out why.

Extra notes I forgot to include in video:
1) You can see that there are a lot of hinge-chains setup (the pink circles) for that character - the character has a frontside skeleton and a backside skeleton, so it is showing the hinge-chains for both of them even though in the video you just see the front side skeleton.
2) The point in time during the intro-cutscene animation where the hinge chains seems to start 'going crazy' is when:
---a) the character finishes standing up abruptly (maybe some upward momentum?)
---b) the character does a quick bit of movement to the right and stops suddenly (momentum again?)


I'd be glad to upload the Spine project, but my guess is that its a setup/configuration issue within Unity.

Here is a video showing the issue:



My team is presenting this demo to a lot of publishers at Pax East this next weekend, and this is the final thing that I need to fix, so I'm in slight emergency-mode. Would appreciate any suggestions or help, or anything I can check on. (Help me Harald, you're my only hope :D hehe)

Oh yeah - follow up question: When you kill the Knight in this demo, time slows down for a bit right after you land the killing blow. I noticed that while time is slowed down, the physics of the Chain Bones seems to update at a separate rate, causing it to look jerky. Not sure if its just how physics works when TimeScale is slower, or if its something specific to the Chain Bones?
アバター
Jamez0r
  • 記事: 126

Harald

Sorry for the troubles and thanks for posting the detailled video! Unity's joints can cause a lot of headaches sometimes.

Guessing from the behaviour seen in your video, it looks as if the problem is as follows:
- At the start, the total bone rotation from the Spine Skeleton is at lets say 350 degrees, placing the physics chain correctly facing down.
- When the character stands up, the total bone rotation changes across the 360 degree border to e.g. 370, resulting in 370 % 360 = 10 degrees.
Now I guess this is what causes Unity's Physics to "freak out", expecting 370 (however Unity tracks this?), rotating it all the way in the other direction by -340 degrees instead of +20 degrees.

So a quick workaround that you could try (before we can find a real bugfix) is adding e.g. a 180 degree rotation offset in the setup pose to the problematic bone in Spine that keeps it away from the problematic 0-degree rotation angle.

When you have time, it would be great if you could send us a small reproduction Unity project to contact@esotericsoftware.com, then we can hopefully come up with a proper fix for this issue. Nevertheless, to be sure to finish everything on time please do not rely on the bugfix arriving in time, as bugfixes regarding Unity Physics are especially hard to estimate.
I noticed that while time is slowed down, the physics of the Chain Bones seems to update at a separate rate, causing it to look jerky. Not sure if its just how physics works when TimeScale is slower, or if its something specific to the Chain Bones?
Hm, this is indeed strange. Changing TimeScale is expected to properly scale down Physics along with it.
You could do a quick test and see what happens when you change the Rigidbody.solverIterations count at the jerky rigidbodies.
アバター
Harald

Harri
  • 記事: 1514

Jamez0r

Harald さんが書きました:Sorry for the troubles and thanks for posting the detailled video! Unity's joints can cause a lot of headaches sometimes.

Guessing from the behaviour seen in your video, it looks as if the problem is as follows:
- At the start, the total bone rotation from the Spine Skeleton is at lets say 350 degrees, placing the physics chain correctly facing down.
- When the character stands up, the total bone rotation changes across the 360 degree border to e.g. 370, resulting in 370 % 360 = 10 degrees.
Now I guess this is what causes Unity's Physics to "freak out", expecting 370 (however Unity tracks this?), rotating it all the way in the other direction by -340 degrees instead of +20 degrees.

So a quick workaround that you could try (before we can find a real bugfix) is adding e.g. a 180 degree rotation offset in the setup pose to the problematic bone in Spine that keeps it away from the problematic 0-degree rotation angle.

When you have time, it would be great if you could send us a small reproduction Unity project to contact@esotericsoftware.com, then we can hopefully come up with a proper fix for this issue. Nevertheless, to be sure to finish everything on time please do not rely on the bugfix arriving in time, as bugfixes regarding Unity Physics are especially hard to estimate.
I noticed that while time is slowed down, the physics of the Chain Bones seems to update at a separate rate, causing it to look jerky. Not sure if its just how physics works when TimeScale is slower, or if its something specific to the Chain Bones?
Hm, this is indeed strange. Changing TimeScale is expected to properly scale down Physics along with it.
You could do a quick test and see what happens when you change the Rigidbody.solverIterations count at the jerky rigidbodies.
Thanks @Harald for the help! What exactly do you mean by adding a 180 degree offset in the Setup pose?
Do you mean to literally rotate the bone 180 degrees (causing the strip of cloth to point straight upward in the Spine project)? Or something like... add an extra bone inbetween the problem bone and its parent and rotate that 180 degrees, and then 'counter rotate' the problem bone back 180 degrees so that it is back to hanging straight down?

Also I'm guessing I need to re-create the HingeChain when I make these changes? Assuming so, yeah

---

Mini-update: What I did was create a new bone and rotated it 180 degrees, and then parented each of the problematic bone-chains to it. I just recreated the hinge-chain for one of them in Unity, and so far it looks to be working! *fingers crossed*

---

@Harald, you invoked your IDDQD powers and saved us. Thanks so much for the help! I'll get the bug repro submitted next week.

---

Setting the Rigidbodys to Interpolate: Interpolate fixed the jerky timescale issue :grinteeth:
アバター
Jamez0r
  • 記事: 126

Harald

Jamez0r さんが書きました:@Harald, you invoked your IDDQD powers and saved us. Thanks so much for the help! I'll get the bug repro submitted next week.
:D Very glad to hear that it worked!
What I meant by adding the 180 degree offset was to rotate the problematic bone in Setup mode in Spine with Compensate active for both Bones and Images, thus only rotating the single bone but not the child bones or attachments.
Jamez0r さんが書きました:Setting the Rigidbodys to Interpolate: Interpolate fixed the jerky timescale issue
Good to know, thanks for sharing!
Then we wish you all the best for Pax East, and fingers crossed for finding a good publisher! :)
アバター
Harald

Harri
  • 記事: 1514

Jamez0r

Harald さんが書きました:
Jamez0r さんが書きました:@Harald, you invoked your IDDQD powers and saved us. Thanks so much for the help! I'll get the bug repro submitted next week.
:D Very glad to hear that it worked!
What I meant by adding the 180 degree offset was to rotate the problematic bone in Setup mode in Spine with Compensate active for both Bones and Images, thus only rotating the single bone but not the child bones or attachments.
Jamez0r さんが書きました:Setting the Rigidbodys to Interpolate: Interpolate fixed the jerky timescale issue
Good to know, thanks for sharing!
Then we wish you all the best for Pax East, and fingers crossed for finding a good publisher! :)
Just wanted to share this video I took of the demo.

The demo uses a lot of the spine-unity bells and whistles:

-Spine Animations for everything that moves on-screen (characters & environment)
-URP's 2D Renderer with lights and normal-maps, using the URP/2D/Spine/Sprite shader
-2D Hinge Chains on the enemy boss, the "bonsai knight" npc's moss hanging off of his head-tree-branch, and the weeping-willow style tree on the left side of the boss arena
-Skeleton Ghost for the enemy boss' leaping and lunging attacks
-Modified version of Skeleton Ghost for the reflections in the puddles in the boss arena
-Spine Timeline UPM for the boss intro & death cutscenes

If you want to cut straight to the boss fight it starts at about 2 minutes in:

アバター
Jamez0r
  • 記事: 126

Harald

Thanks for sharing! Very cool, I really like the boss appearance and animations! Good job! 8)
アバター
Harald

Harri
  • 記事: 1514

Jamez0r

Thanks :grinteeth: :grinteeth:

Alrighty, made the repro project and posted this ticket: [unity] 2D Hinge Chain rotation issue (repro project) · #1636
アバター
Jamez0r
  • 記事: 126

Harald

Thanks for the repro project and filing a perfectly filled out issue ticket! :nerd:
アバター
Harald

Harri
  • 記事: 1514


Return to Unity