I’m using Unity’s 2D animation system to animate a character. They’re a pretty standard humanoid sprite with two legs and two arms.
In order to be able to change the images on individual parts of the model, I have separated it into several sprites - one for each limb, the body, the head, the eyes and the mouth. I then assemble it in the editor by creating and skinning each one of them as its own skinned sprite and parenting them to the correct bones. This lets me animate them as a whole, while swapping independent parts at will to achieve things like facial expressions, gripping hands and mouth animation.
However, I have a problem. I want to have the sprite point his hand at a particular target. In order to do this, I need to somehow override the current animation for a portion of the model with my own values. I’ve tried a couple of methods to achieve this, with no luck.
First I tried using LateUpdate to manually set the bone’s rotation. I tried modifying rotation, localRotation and localEulerAngles, all with the same effect. It just made the sprites move to completely incorrect positions, even though I was only changing their angle. Basically, the arm detached from the body and the hand from the arm, possibly because they were different sprites parented to those bones. What’s more the animation was still affecting them, as if it were being applied after LateUpdate.
So I tried adding Inverse Kinematics. I tried putting it on the parent object and on the individual sprite to be affected. In both cases it partially worked in that the arm would point to the target, but again the individual sprites got ripped apart so that they were no longer attached in the correct places.
Can anyone explain what I’m doing wrong? Or is this simply not possible because you can’t use the sprite resolver to change a portion of a rigged sprite without changing all of that sprite?