toby

Oh hi there.

IK works perfectly for profile view animations. But every animator knows that characters walking/running directly toward/away from the camera is tough.

Part of that is having to scale the bones instead of just bend the joints. Unfortunately, when I scale the upper leg bone with IK at 100% it starts to rotate for some reason. It rotates when it scales down to about .6 or so.

Anyone else come across this? Work arounds? Solutions?

Thanks!
toby
Posts: 8

Erikari

Hi Toby (:

I can just assume because you didn't post screenshots, but I think that since the IK is always pointing to a bone but in a little chain of two bones, if space is not enough, it starts bending more. Same for the opposite case, if there's more room, it will be straight, I believe once it's straight it doesn't rotate anymore, does it?
What you can do is lower the influence of the IK in the specific part of the animation where you need to scale it, or you just rearrange the IK so it doesn't look like it's moving in the specific frame.

If you need to scale those often, you can consider having a second set of bones children of the leg bones, and you just scale those instead of the ones with IK. I recommend the first solution though.
User avatar
Erikari

Erikari
Posts: 695

toby

Sorry about no screenshot. I'm only mean when there's lots of space. Like when the target bone is not touching either of the leg bones.

As shown here...

https://imgur.com/a/w3m3G

...the IK constraint is absolutely at 100 mix.
toby
Posts: 8

Erikari

From the screenshot it looks like the target of the darker leg is the dark foot and not the orange IK target, could you attach this project here?
User avatar
Erikari

Erikari
Posts: 695

toby

Ok yes, thank you.

..so on frame 9 of 'run' the upper leg is scaled down. But doing so makes the knee bend.

Hopefully that makes sense.

Regardless, thanks for your time!
Attachments
test.spine
IK test rig
(3.88 KiB) Downloaded 66 times
toby
Posts: 8

Erikari

Hey Toby, if you use non-uniform scaling it is possible for this to happen, at first I thought the IK target was the foot, turns out you were right :)
Just try to keep the values similar to avoid this.
User avatar
Erikari

Erikari
Posts: 695

toby

You mean keep the X and Y values similar?
toby
Posts: 8

Erikari

Yes. Non-uniform scaling can cause this behavior.
User avatar
Erikari

Erikari
Posts: 695

toby

Ok but I need non-uniform scaling for a non-profile walk/run cycle; and for other animations potentially (unless there's another way to fake foreshortening).

So I need IK so I don't have to counter animate and I need non-uniform scaling to fake foreshortening. I need them at the same time too, is there nothing for me? I have to imagine someone somewhere has used spine to animate walks in this perspective.
toby
Posts: 8

Nate

When an IK constraint is applied to two bones, we call the bones the parent and child. IK rotates the parent and child so the tip of the child is at the target bone, or as close as possible. When you put non-uniform scale on the parent, the rotation of the child changes the length of the child. This is because the child inherits scale from the parent, so the direction the child is pointing changes the child's length. The IK solution you see is correct, even if it is not intuitive. If the parent and child pointed straight at the target, then the child would be shorter and therefore further from the target. You can remove the IK constraint and see this by rotating the bones manually.

I understand you don't like this behavior for your animation, but that is how IK works. Probably it is odd to scale an upper leg bone, since that means the lower leg bone will change length as the leg bends at the knee.

One solution could be to add a new bone. Maybe you can add a new bone that is the parent of the IK parent bone, then scale that bone instead of scaling the parent bone. Or add a new bone that is a child of the IK parent bone (ie a sibling of the IK child bone). Move your images to the new bone and scale that bone to change the image sizes. You could translate the child bone to be in the right place.

Another solution could be to set the IK mix to zero for this animation. The way you are using IK in that animation is to counteract the rotation of the hips, which could be done with rotate keys. Or, you could set a transform constraint, like in the attached project.

---

Here is the current IK solution:

Here is the same but without compensating for nonuniform scale on the parent IK bone:

As you can see, the IK is incorrect -- the goal is for the tip of the child bone to be at the target.

Here's a pose from your actual animation:

Here is with nonuniform compensation off:


Admittedly it doesn't look much different, but zooming in you can see the tip is closer with the current solution:

Than with nonuniform compensation off:


Not a big deal you say? Only for your particular case, where the bones are straight. :wait: If not applying nonuniform compensation, IK breaks completely with nonuniform scale on the parent bone:

This is because when the bones bend, the child changes length. If it doesn't compensate for that, the IK solution is wrong (the child tip is not as close to the target as it could be). That we support nonuniform scale on the parent at all is the result of an extreme amount of effort and late nights with math books. :nerd:
Attachments
test-transform.spine
(4 KiB) Downloaded 48 times
User avatar
Nate

Nate
Posts: 7625

toby

What a fantastic reply! I really appreciate you guys investing so much time into us! This is one of the reason I love using Spine.

Oh man, my mind boggles. I think I ALMOST understand what is actually going on. I can see it's VERY complicated to get IK to work at all.

So, if I add a new parent to the leg parent bone and scale that, it works great only if the leg is straight and aligned with that new parent. Not ideal for complicated kick animations.

If I create intermediate leg bones to house the leg images ('hip' and 'knee' bones) and scale those, it can work. Though, it's not ideal to have individual bone transforms split into multiple bones.

If I set the IK mix to zero I'll have to counter animate for the pelvis like you said, which defeats the whole point of IK.

Ideally I'd be able to set the child leg bone to not inherit scale, but I understand that's incredible difficult to code and isn't something I should hope for in the future, is that right?

Thanks again for all your time guys! The fact the Spine exists in the first place is wonderful!
toby
Posts: 8

Nate

Thanks for understanding! :happy:

It's true counter animating the pelvis instead of using IK would be unfortunate, but if it's only for a couple animations it might not be so bad.

IK is already quite complicated (if you'd like a headache, check out the code :p), so we chose to not support disabling inherit scale, which would add a number of new edge cases that we'd need to handle. We have to make sure there is never a case where IK is wrong, even if the case is rare. It's not impossible that we revisit that decision, but we don't have plans to in the near future.

Another workaround you could use is to have a second set of leg bones. You can use single bone IK on the upper leg bone, which will result in the bone always pointing to the target. For most animations you'd probably use the 2 bone IK and hide the other leg attachments.

That reminds me, we should lift the restriction about having multiple IK constraints on a single bone, now that we have reorderable constraints. Then you wouldn't need 2 sets of bones, you could just disable the 2 bone IK and enable the 1 bone IK.
User avatar
Nate

Nate
Posts: 7625


Return to Editor