Hi there!
On my current project, I've been working with 2D-rigged Sprite characters for the first time, thanks to the great
Anima 2D skeletal animation Plug-In, which has been acquired by Unity and now is for free – a lovely and highly efficient tool I can recommend to everyone!
So far, I've been able to make it work with AC beautifully, and am quite content with the new freedom and flexibility that 2D-rigging allows for.
There's only one catch where Anima2D and AC don't really go together so far: Managing Sorting Layers by SortingMaps.
It took me quite a while to find out why it would not work, and my current understanding is that this is because AC's SortingMaps affect the "Sprite Renderer" component, but with Anima2D's rigged characters the Sprite's Sorting Layer is stored in the "Sprite Mesh Instance" component instead, and the Sorting Map won't override that because it's looking for the Sorting Layer in the Object's Sprite Renderer instead. Which isn't there.
As I said, that's just my understanding.
Now, is there any way a future update could enable Anima2D's rigged characters (that is, their "Sprite Mesh Instances") to follow Sorting Maps, too? It's really sad having to restructure rooms in a way that there's only fore- and backgrounds because my character always has to be on the same Sorting Layer, as it cannot change depending on its position.
I'd be happy to elaborate if necessary, but I hope I could get across where the problem lies.
As Anima2D now is a new and now "official" part of Unity's 2D Sprite Animation workflow, I think many more people would appreciate a way to make this work.
Thanks in advance for any thoughts!
Comments
I'd first recommend you look into using its Skinned Mesh Combiner component so that you only have to deal with one Sprite Mesh Instance at runtime, which should make things easier.
The Follow Sorting Map component indeed looks for Renderer components, but I expect that you could attach an empty Sprite Renderer to it (so that it is affected by the FSM) and then include a custom script that simpl copies one to the other, i.e.:
void Update ()
{
GetComponent <Anima2D.SpriteMeshInstance>.sortingLayerName = GetComponent <SpriteRenderer>.sortingLayerName;
}
The component works by modifying the "Order In Layer" (or "Sorting Layer Name", depending on what you've chosen) field in a Unity SpriteRenderer component. However, since Anima2D relies on its own SpriteMeshInstance component for drawing its sprites, the FSM won't have any visible effect.
Therefore, I'm suggesting that you create a "dummy" sprite on the GameObject, which the FSM can affect, and then have another script that transfers its values onto the SpriteMeshInstance.
With the code snippet I wrote, all the components in question should be on the same GameObject - though this code be changed if you wanted.
http://adventure-creator.wikia.com/wiki/Anima2D_and_sorting_maps