- Modifié
Issues with IK and flipping bones
A bit of explanation about the setup we have, this character is meant to be able to face in 8 directions with their torso separate from their legs for aiming. 4 of the directions are mirrored, so rather than draw and animate them again we set the x scale of the appropriate bones to -1 to flip them.
The issue though is that the when we flip the torso the IK control bone ends up pointing in the wrong direction like so:
If I use the Skeleton Utility component during runtime though I can select the control bone and see that it's not actually pointing the wrong direction, the red right arrow matches my input it's just that the IK control bone is pointing in the opposite direction.
Here's what I've tried so far:
I did some poking around and stumbled upon another post that mentioned bone inheritance, so I thought that maybe since the IK control bone was under the torso that was being flipped that was affecting things, but disabling the scale inheritance on the control bone didn't do anything.
My next idea was to also flip my input values, and it kind of worked, but sometimes when flipping it flickers for a frame showing the IK with un-flipped input values.
At this point I felt that I had maybe gone too far in the wrong direction since having to flip the input was kind of weird. So I did some more thinking and and looking around and thought that it might be due to the animations. Since the IK control bone was also keyed for some things it would make sense if maybe that was what was causing things right? But removing all the keyframes from the animations that used the control bone didn't do anything either.
I also tried adjusting the scale of the entire unity object when flipping, and that actually worked, but because the legs and torso have to be able to flip separately it meant I couldn't really use it as a solution.
Now I'm thinking that maybe it's something with the way I'm setting the rotation of the IK control bone, or the way that flipping is handled. Both the flipping and setting the IK control rotation are done on the skeleton's UpdateLocal, but as far as I know that should be correct?
Honestly at this point I'm kind of stumped and any ideas would be great. I normally work on the Unity side of things, so apologies if there's something obvious I'm missing in regards to rig or how things should be set up.
If your setup is only behaving incorrectly for a single frame only, I would guess that this problem lies on the runtime side of things. Using UpdateLocal
is correct, however.
Nevertheless, a rig setup should be possible where you don't need to invert your input values and let everything be handled by the Spine rig. I'll leave this answer in more capable hands, you should see another reply down below soon.
Hello! Chiming in for the rigging/editor part!
arcadim a écritsince the IK control bone was under the torso that was being flipped that was affecting things, but disabling the scale inheritance on the control bone didn't do anything.
If your IK target is a child of the torso, I think this may be the root cause of the problem. If you look at the way Spineboy or Gunman are structured, the target has to be independent from the rest of the hierarchy.
Is this the case or does " IK control bone" mean something else for you and the structure is actually different?
In the case that the above replies does not help, you can email us the spine project at <removed> and leave a link to this thread in the email. I'm assuming it's not something as simple as having reflection
turned off for the torso, but without seeing the rig it's hard to tell what the actual problem might be.
Erika a écritIf your IK target is a child of the torso, I think this may be the root cause of the problem. If you look at the way Spineboy or Gunman are structured, the target has to be independent from the rest of the hierarchy.
I think this was the case. The bone we were rotating was just under the torso, but when setting up another bone outside of the torso to use as the IK control it seems more promising. I need to adjust some things for this new setup but will report back with more details later.
Yep it was the bone hierarchy setup! Having a separate IK bone outside of the torso that was being flipped fixed everything.
Thanks again for all your help!
Cool character setup - I'm a fan of games with that camera viewing-angle (making a game like that myself). Can you share any info on your project, twitter account or anything? Would like to check it out