Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Help with Unity 2D Skeletal Animation

Discussion in '2D' started by Nervly, Aug 8, 2019.

  1. Nervly

    Nervly

    Joined:
    Mar 15, 2016
    Posts:
    19
    Hey, I'm relatively new to Unity, as a whole, and I've been looking into its 2D Skeletal Animation tools. Out of the ones I've researched, mainly Anima2D and the preview 2D Animation package, I can't seem to find the proper answers/documentation to what I want to know. I'm not exactly sure how to best explain my questions but I will try and provide references to further exemplify. I'm just looking for clarification. I'm sorry if this all seems a little disjointed, confusing or over-complicated; my naivety and lack of experience on the subject is more than likely what's holding me back.

    The animation system I'd intended to implement is similar to that of Rayman Legends'; a sprite atlas with all the various pieces set and rigged individually, to be mixed and put together in order to make an animation. One issue I've had is, and I don't know if this is certain, you need to keep the sprites as children of the game object? Otherwise, you can't play your animation because objects are missing. Is this correct?

    I want to know if there is a way to, or it is already automatically done and I'm just not aware, to store that data in the animation file; so as to only call the pieces relevant to that particular animation, similarly to a traditional frame-by-frame sprite animation, as opposed to them all being part of the game object running said animation already.

    I don't aim to have just one single bone rig be used for a character's entire list of animations; like a 3D model would. Some animations might use more bones than others, some might not need as many. Using the exact same rig and pieces of the sprite for every animation is not at all what I'm looking for. Like I said, I want to pull different pieces from a big pool of images. Though, at the same time, tutorials about these tools that I've seen, don't demonstrate such a feature, if there is one. But there not being one just seems odd, to me.


    In short, what I'd like to know is:

    - Is it possible to bind bones to individual sprite meshes and call on these rigs only when the animation is played, independently from the game object?

    - Is it possible to swap, add or remove pieces of a sprite in the middle of an animation?

    - Am I required to set a permanent rig for the game object intended to play several different animations or am I able to have several individual ones and use only the ones pertaining to a certain animation?

    - Do either of the aforementioned tools allow me to do any of this?


    Any and all feedback would be appreciated, and let me know of anything I might have misunderstood on the subject. Thanks in advance!

    Here is the link to a video explaining Rayman's animation process within their engine:

     
    Last edited: Aug 8, 2019
  2. Shack_Man

    Shack_Man

    Joined:
    Jun 7, 2017
    Posts:
    372
    I'm curious why you would want to have different rigs for one character. Isnt it possible to do all animations with one, can you give an example?
    Maybe it would help you to break down the character, have one animator for each part like head, torso, legs?

    It is very easy to swap single sprites, so not sure what you mean by removing pieces. If you want to modify the sprites at runtime that's a bit more complicated.
     
    Nervly likes this.
  3. Nervly

    Nervly

    Joined:
    Mar 15, 2016
    Posts:
    19
    Thank you so much for taking the time to read and helping me with my situation.

    With a single rig, games, that I've seen, just use the same pieces for every animation; which makes them look very indistinguishable and samey, in my opinion. In a 2D perspective, if their arm (closest to the camera) was lifted up, they wouldn't change the sprite to the arm's underside; it would just be the same image flipped upside down, essentially. So, I've been looking for a way to avoid this and make animations appear more natural.
    I hadn't thought of using individual animators as a possibility. I'll keep that in mind.
    By removing or swapping, I just meant using other parts from the atlas in the different animations; as opposed to using the same ones for them all.

    I'm looking for the closest way to animate to Rayman Legends, and want to know if it's possible.
    My end goal would look something like this:



    Note: Using Barbara as the example simply for her more understandable humanoid design.

    An atlas with all the individual parts of a character; and not just use the same ones in every animation. As mentioned before, one animation might show the outer part of an arm but another might show the inner. In this case, I'd want to have two different images for the arm, to be used at different times. This would also apply to other parts like the legs, head, torso and whatnot. And with them being shown from different angles, I would figure the rig would not be the same.



    From what I've gathered, Rayman appears to do this, as shown in the video, and the reference below. I'm almost sure that Anima2D is capable of something identical, from what I've experienced; particularly, applying bones to individual images to bend and twist the mesh accordingly. As the picture below illustrates, the highlighted piece has 2 bones bound to it.



    What I'm not sure of, is if that tool provides the same freedom and allows me to keep the rig separate from the character and only using the meshes when an animation calls for them, as Rayman does.
    I want to know if this is possible to achieve with this tool or by any other means.
     
  4. Shack_Man

    Shack_Man

    Joined:
    Jun 7, 2017
    Posts:
    372
    EDIT: just found out you can simply swap sprites when recording an animation, it records the swap!


    I'm not sure but I think rig refers more to the bones, so that's why I was confused. I thought you wanted to make one character and create different skeletons. If I understand correctly now, what you want is one skeleton (rig) and be able to change the sprites. That is certainly possibly. If you want to have different sprites for the whole animation, I'd change the sprites via script. E.g. you could have a run animation, but if the character gets blasted by a flamethrower, you want to use the same animation but replace all sprites with burned looking ones.

    You can also change sprites within an animation, like the arm example you gave. You could attach multiple sprites to one bone and when you create the animation, you simply activate/deactivate the game object that contains the sprite at a certain frame.
    You could also use animation events and once again change them via script. I don't know which one is better for performance though.
     
    Last edited: Aug 16, 2019