Forum rules - please read before posting.

Anima 2D Sprite Meshes

edited July 2017 in Engine development
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

  • edited July 2017
    I've been playing around with Anima 2D myself for another project and I agree it can be useful.

    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;
    }

  • Hi Chris,

    Could you please elaborate a bit more on the second part?

    1. What do you mean by "so that it is affected by the FSM"? How do I achieve that?
    2. The custom script should be another component on the same GO that the 'follow sorting map', 'Skinned Mesh Combiner ' and 'Sprite Renderer ' components are on?

    Thanks!
  • By FSM, I'm referring to the Follow Sorting Map component - which resizes a sprite and changes it's order in layer value as it moves around the scene, in order to create the illusion of depth.

    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.
  • Thanks a lot for the clarification.
    However I'm still struggling to implement it.
    The first pic I attached shows the player character hierarchy, the relevant GOs (FSM, Skinned Mesh Combiner, Sprite Renderer and the script component) as well as the error msg I'm getting from entering the code snippet you wrote (see code in second picture).
    Can you spot what am I doing wrong?
    Thanks!
    imageimage
  • That "Default" is the problem, and I don't know where that's come from - but I since added the necessary script to the AC wiki:

    http://adventure-creator.wikia.com/wiki/Anima2D_and_sorting_maps
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.