- Home /
Animating a Sprite from Parent Animator
I've created a 2d character for my game that uses both bone based animation and frame-based spritesheet animation.
For most of the different parts of my character, attaching an animator directly to the component (Hands, Head, etc.) and animating the sprites directly on the same GameObject works fine. However, in order to sync the sprite animation of the body with the walk/run cycle (which are bone based animations), I have to animate the body's sprite from the parent game object (which animates the arms and legs for the walk/run cycle).
However, I'm unable to add the 'Sprite' property of the child (the body) to an animation in the parent (a mostly empty gameobject holding a hierarchy of 'bones' for the character).
Typically, when wanting to animate a property of a child, I expand that child's hierarchy in the animation window and click the 'plus' button next to the desired property. However, this plus button is missing from the 'Sprite' property:
I have, in desperation, tried dragging the sprite directly into the animation, but it just adds a sprite renderer to the parent.
How can I accomplish this?
Answer by FortisVenaliter · May 20, 2016 at 04:51 PM
You shouldn't use multiple Animators, you should use one on the parent, and add the parts that need to be animated separately to their own layers in the AnimatorController.
I forgot about animation layers. I've never used them, but, depending on their capabilities, it might seem that this would be the solution.
Would animation layers allow animating the 'bones' of a character for a run cycle and animating the sprites of a hand in a cycle which is independent of the walk cycle, and having both animations play at the same time?
Without this answer, I never would've figured this out, but I should add more information for anyone encountering this problem in the future:
After removing the animator from my body, I was able to select the parent object in the inspector, add the sprite property of the body to the animation, select the body in the inspector (while still having my animation persist in the animation window) and switch out the sprite for the body in the inspector after selecting the appropriate frame in the animation window.
Works like a charm! Thanks!
Your answer
Follow this Question
Related Questions
2d Animation sprites - right way? 0 Answers
Lighting an Animated Player 0 Answers
How to swap sprites? 1 Answer
2d sprite animation issue 2 Answers
Animating hair over sprite animation 0 Answers