NSantos

Hello there!

I have been having an issue regarding the blending between two animations.

The following happens:
https://imgur.com/964qtym

It seems some bones rotate all the way around instead of blending to the next nearest position. Any ideas what the issue is and how it can be solved?

Kind Regards,
Nuno Santos
NSantos
  • Postovi: 7

Nate

When AnimationState mixes rotation between two animations, it needs to choose to mix either clockwise or counter-clockwise. On the first frame of the mix, it chooses the direction that results in the smallest rotation. It then uses that direction for the rest of the mix. Sometimes that may not be the direction you want.

For example, the rotation could be 175 degrees around one way and 185 the other. Those are similar and one may look better than the other, but Spine will choose the shorter rotation direction (175) and use that same direction for the rest of the mix.

Problems can also occur when the shortest direction becomes the longer direction after the first frame of the mix. Remember we are mixing two animations that change over time. The animations may be rotating the bones in a way that makes the direction that was the shortest at the start of the mix become the longer direction for most of the rest of the mix. That may look odd in some cases.

My guess is that is the cause of your problem: your animations are making large rotations and the initially chosen shortest rotation mix direction becomes the larger way around shortly after the mix starts.

You could try using a shorter mix duration and see if the problem goes away. A mix duration of 0 won't have the problem, of course, but may not look good. You may want to check if the rotation of the hip or root bone is very different from the idle rotation, indicating that your character is landing nearly upside down and the mix may not look good. In that case you could use a shorter mix duration, possibly even 0. Another way to check when the character has a lot of rotation compared to the landing pose could be the TrackEntry trackTime of the jump/flipping animation.

By sticking with the initial choice for the rotation mix direction, AnimationState ensures there is no snapping during the mix. You can set TrackEntry shortestRotation to true to have AnimationState use the shortest rotation mix direction of the current poses. Unfortunately this will result in snapping if the short way around becomes the long way around as the rotations from the animations change over time. That may look OK for your use case of the character landing from nearly upside down.

A related feature is TrackEntry resetRotationDirections. This causes AnimationState to forget the current rotation mix directions. It will choose the shortest way around the next time the AnimationState is applied and remember that for the rest of the mix. resetRotationDirections can be useful when using alpha and starting animations on other tracks, but may not be helpful for your problem.
Avatar
Nate

Nate
  • Postovi: 12208

NSantos

Thank you so much for your quick answer.

I think being able to choose the shortest rotation or not based on the player reaching a certain threshold of the jump flip animation might be a possible solution and you've certainly given me a lot of tools to experiment with.

Thanks again!

---

Another question: Is it possible to enforce using the longest rotation? I thought setting the shortest rotation would work but I'm in a bit of a struggle here.

Thanks in advance.
NSantos
  • Postovi: 7

Nate

No, you can't force the longer rotation direction. You probably wouldn't want to. It might look better for the hip or whatever bone is rotating most of the character, but will look bad for everything else (arms would go around the wrong way, etc).

How does setting shortestRotation to true look?
Avatar
Nate

Nate
  • Postovi: 12208

NSantos

So, I have set up a test scene to debug these cases and I attempted to make the mix after the animation is completely finished and I noticed a few interesting things:

Flip Track Entry Shortest Rotation(true): https://imgur.com/h5oYMis

Land Track Entry Shortest Rotation(true): https://imgur.com/C6PI8mp

Flip/Land Track Entry ShortestRotation(true): https://imgur.com/5Eyug2d

There seems to be an issue with one of the central bones since it completely twist his waist when using the shortest rotation.

Thanks in advance.
NSantos
  • Postovi: 7

Nate

Hmm, that doesn't look right. Can you email the JSON and atlas files so we can look more closely at what is happening? contact@esotericsoftware.com
Avatar
Nate

Nate
  • Postovi: 12208

NSantos

Hello again!

Sorry to revive this post but I have sent the requested email almost two weeks ago and I haven't got any response yet. Just wanted to confirm if you did get it and/or if there are any updates on this issue.

Thanks in advance.
NSantos
  • Postovi: 7

IndieDoroid

Spine 4.0.64 pro

I've been having this issue for the last couple of years. Not sure how to fix it either.. when I check my spine rotation values, the hip and spine of both animations have similar ending\starting values. IE: One rotation start\ends with 70 and the other animation start\ends with 90.

It might be your spine version too? Maybe it's fixed in 4.1
I set Spine's mix duration to 0 and it still happens. :upsidedown:
https://imgur.com/uhAQM52

But a possible alternative is, if you can live without smooth transitions, is by removing Unity's transition duration. Uncheck Fixed and make the transition to 0. This is what I resorted to in the end.
Illustration.jpg
Nemaš dopuštenje za pregledavanje privit(a)ka dodan(og)ih postu.
Avatar
IndieDoroid
  • Postovi: 263

Harald

We are very sorry for the long delay, the mail must have slipped through (likely the notification for Nate got lost in a very busy week)! :wounded: We have received your email with the reproduction project and will get back to you soon.

---

IndieDoroid je napisao/la:I set Spine's mix duration to 0 and it still happens. :upsidedown:
https://imgur.com/uhAQM52
How do you set the MixDuration? If you still see a transition over multiple frames, something has gone wrong and was not applied properly.
IndieDoroid je napisao/la:But a possible alternative is, if you can live without smooth transitions, is by removing Unity's transition duration. Uncheck Fixed and make the transition to 0. This is what I resorted to in the end.
Illustration.jpg
If the default mix duration setting affects your animation transition, it is an indication that your call to trackEntry.MixDuration was not executed as it should. Just asking to rule that out: was it perhaps executed on the first (the animation to mix out) of the two animations instead of the newly added animation (which will be mixed in)?
Avatar
Harald

Harri
  • Postovi: 4451

Nate

Sorry for the late response!

As Harald mentioned, a mix duration of 0 has no mixing -- the transition from double jump to idle is instantaneous. It should not be possible for you to see bones rotating the wrong way around. Instead they instantly change from whatever pose double jump was applying to the idle animation pose with no mixing at all.

Looking into the skeleton data you sent, the double jump is animating the body bone from 69 to 228 degrees. When you mix to the idle animation, body is at 74 degrees, so the mix transitions from 228 to 74. That is quite a long rotation and I see why you don't like the result (it sort of unwinds the rotation made during the jump to get back to the setup pose).

We found the "shortest rotation" TrackEntry setting is not actually working as intended. I modified AnimationState to try out using the shortest rotation direction, but the result isn't great because various bones jump from one way around to the other. Which do that depends on the timing of when the jump transitions to idle. Since shortest rotation isn't working anyway, we should either fix it or remove it in 4.2. I don't think the setting is useful very often, because it's not usually tolerable to have bones jumping to the other side, so I'm inclined to remove it.

I think the best results for you can be had by letting the jump play as long as possible and use a 0 mix duration to get back to the idle animation. Or, you could try a "landing" animation. You'd use it by changing from jump to landing using 0 mix duration, then you could either mix to idle or let the landing animation animate to idle.
Avatar
Nate

Nate
  • Postovi: 12208

NSantos

Thank you for getting back to me!

I am gonna make some further tests and try to fix the issue - I'm thinking about letting the animation mix if it is at less than around 30% duration (mixing back naturally) and if not, assuring that the animation goes through by 75/80% before transitioning to the idle one (maybe even speeding it up a bit then). Whatever it takes to make it feel right.

Thanks again.
NSantos
  • Postovi: 7

Nate

That sounds perfectly reasonable.

I was thinking, another way to visualize the issue is an image that is spinning, then mixing to the setup pose to stop. Depending on where the mix starts, you'll get different results during the mix duration. Here I start and stop the fan a few times:

It doesn't come through great in the GIF, but depending on when the fan is mixed back to the setup pose, sometimes it comes to a stop by rotating forward, other times it reverse to get there.
Avatar
Nate

Nate
  • Postovi: 12208


Natrag na Unity