Forum rules - please read before posting.

Swapping individual 2D sprites with Layers and Object: Animate

edited August 2020 in Technical Q&A

Hello to all!

I was curious and wanted to find out something regarding Animation Controller Layers.

Currently using Unity 2019.4.4f1, AC 1.71.7, and Unity's 2D Animation Package to animate my characters, which are made up of individual sprites in a PSB file that's imported.

I read in this AC thread that Animator Controller Layers can be used to control which sprites a charater's body / leg / arm SpriteRenderes display (Understandably, the thread is discussing Anima2D, though the part about Layers sounds as if it can be universal for all characters composed of separate sprites, bones, etc.):

Changing your character's clothes could also be done through animation. A further Animator controller layer could control which sprites your character's body / leg SpriteRenderers display, which could be controlled by another parameter - and in turn, another Object: Animate Action.

As I'm interested in the approach with parameters and Object: Animate, I was wondering if swapping out, for instance, just one or two individual 2D sprites at a time using Layers is possible.

The way I understand it with 2D, Layers can have an "appearance" of swapping out a few individual sprites by switching / overriding animation clips that were pre-animated beforehand.
And that Layers switching the individual sections of a character are more attuned to 3D, as those use an avatar and masking.

For 2D, I was able to accomplish switching individual sprites by using Unity's Sprite Swap feature:
https://docs.unity3d.com/Packages/com.unity.2d.animation@2.2/manual/SpriteSwapIntro.html

Different animation clips were created for a new "skin" (outfit) in which the body / arms / legs sprites are "activated" using Sprite Swap's "Sprite Resolver" components attached to each sprite that has a Sprite Renderer -- to show the new "skin" (outfit); Then showing those completed animation clips using Object: Animate.

This process is good -- Though was wondering if Layers could be used to swap individual sprites as well, like mentioned in the thread above. And if so, how to go about that.

Thank you for any assistance or ideas!

Comments

  • FWIW, Character: Animate should be appropriate here - not just Object: Animate.

    This is more of a Unity usage issue, but layers can be used not just to override properties of base layer animations, but also to control properties that the base layer doesn't control.

    For example, if your Base layer animations only deal with the rotation / position of your various body parts, a sub-layer could separately deal with what sprites are assigned to each Sprite Renderer.

    Let's say you want to control what "shirt" sprite is assigned to the Chest SpriteRenderer. You can create a new "Shirt" layer that has a default clip which sets the sprite to "Red shit" (or whatever the default appearance is). Then you can add in another clip that sets it to "Blue shirt", with a parameter controlling transition between the two. So long as this Sprite Renderer's Sprite property is not controlled in any other layer, changing this parameter with the Action should cause the sprite to change.

  • Thank you for that, Chris!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.