1
\$\begingroup\$

I have an animator with two layers, an axe layer and a body layer.

I would like to animate the two in sync with each other. They are both 64x64 sprite animations, frame-by-frame bitmaps.

The problem I'm having is I can't figure out how to alpha blend the layers. The axe either plays and the player body becomes invisible, or the axe isn't visible.

I have a bunch of states like this which each return to an idle state. And link to an animation. I'd post a screenshot but I'm not allowed.

The axe layer is set to sync so the state machine looks the same, and I set the motion to the axe animations rather than the character body animations.

\$\endgroup\$
  • \$\begingroup\$ Please share screenshots of animator controller's settings of both layers for clarifications. \$\endgroup\$ – Inzi Butt Jul 14 '16 at 8:13
  • \$\begingroup\$ Layers are usually used for 3D animations that share common avatar and masking them. You said they are sprite animations. In case of sprite animation, axe/prop animation is done with main animation sprites or separate object animation with separate animator. Are you using any skeletal system to animate? \$\endgroup\$ – Sourav Paul Jul 15 '16 at 11:30
  • \$\begingroup\$ I'm not using any skeletal system, just sprite sheet animations. I originally tried this with two separate animators but the animations were out of sync. \$\endgroup\$ – dave Jul 15 '16 at 11:33
1
\$\begingroup\$

Layers are usually used for 3D animations that share common avatar and masking them. You said they are sprite animations. In case of sprite animation, ax/prop animation is done with main animation sprites or separate object animation with separate animator.

If ax's animation is a sprite animation then you have to create an extra state of animation that has both body and ax animation sprite drawn combined.

If it's a transformation animation then you can put the ax as a child object of the body and animate in the animation tab with the same body animation. Ax sprite can easily be synced that way in whichever frame you want.

If it's a component(enable-disable) animation you can easily do it as same above. All child objects and most of their components are accessible from animation.

For syncing with two animator call the ax's methods from body's animation's Animation Event. If ax has some proposes in the game like it goes in and attacks all the enemies in the scene then you should do it this way. If it just damages opponent when in attack state then go with single animator ways as you need.

\$\endgroup\$
0
\$\begingroup\$

I know this is an old question, but I wanted to put in my two cents as well. Plus this QA is still popping up on Google. So... yeah.

Using Animation Layers with 2D Sprites is still useful. Just not in the way you the OP was trying. You might put the legs in layer1, the body in layer2, and the eyes in layer3. You'd have to re-implement the decision on which way the sprite is facing. But the legs could go walking while the arms are idle, or while the arms are swinging. Or the legs could be idle regardless of the arms state. And then the eyes could blink randomly regardless of whatever else you're doing.

So the whole purpose of those layers is trying to desync the animations.

I'm actually trying to look up the same thing as the OP so I can use layers from the LPC character creator to dynamically create characters. Demonstration and Sprite Sources

And I want to do this without going overboard on resources. I'm not entirely certain how I'll go about it, but here's an idea for it:

A script automatically generates and keeps track of children sprites. If there's a sprite object that it doesn't know about on the character, it will delete it when it updates the sprites on the object. There is one Animator Controller base. There will be like... 5 to 20 children sprites per character. Every sprite has an Animator Override Controller. The script that keeps track of the multiple sprites/controllers will iterate through the list to change/trigger parameters on all the controllers, based on one change/trigger given to the script.

I need to test how resource intensive this is. I also need to test how in-sync it is. If it's not in-sync enough, I'll need to add a reset trigger maybe...

In addition to that, I'm in the middle of writing an EditorScript to automatically process LPC animation textures, slice them into sprites, and animate them so they're all identical for any given selection of textures.

If the animations have slightly different timings though, the shared controller override idea would fail. The second option I'm looking at is making my own animator of sorts that just runs on a schedule and changes all the sprites based on an array passed in. But for some spritesheets (doesn't include a particular motion), it would require repacking, which I don't really want to do very much. So my auto-animator makes more sense than that...

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.