- Home /
How can the animation on one bone drive another bone?
I have a character setup with several animations. I'm using the legacy animation system. Instead of making several versions of the same but mirrored animations, I thought it would be better for performance to use an existing animation to drive different bones of the same clip.
For example: Say I have a hand wave animation on the right arm, and I also need a hand wave animation on the left arm but I don't want to create the extra clip, to reduce file size.
How could I sample the animation of the right hand wave and apply it via script to the bones of the left arm but without destroying the the right arm animation? Basically the way I would imagine this working is by overriding the existing animation in a similar way that the Head Look Controller or the Locomotion System does. So the effect could be switched off (by disabling the component for example) which would play the right hand wave animation, but when turned on the animation clip would play the left hand animation instead. How could this be done?
Answer by Hamesh81 · Jan 19, 2014 at 01:18 PM
Woohoo I've worked this out myself again! It's actually quite a straight forward process once you work out a few issues. First of all you need to store the rotations of all the bones you want to mirror as a quaternion. Then it is a simple matter of multiplying the local rotation of the bones by -1 on specific axes to get the rotation to mirror for the bones. Lastly make sure you do all of this in LateUpdate so that it can be applied after the animation. And that's it! Hope this is helpful to someone.