Search Unity

Using Mecanim with 2D characters/sprites

Discussion in 'Editor & General Support' started by Demigiant, Nov 29, 2012.

  1. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Hello,

    I was wondering if Mecanim could be used to animate 2D characters composed of sprites/quads, or if it's only for 3D stuff. Thanks for any info about this.
     
  2. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    Mecanim can only animate Transform right now. We do want to add more support for everything else in a future release.

    Sonny
     
  3. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Thanks for the info Sonny, though I'm not sure I understood this correctly. If it can animate Transforms, it means that it can animate a 2D character made of quads (where each bodypart, for example, is a GameObject composed of a quad, a renderer, and its own Transform)?
     
  4. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    if you have a transform it should work, what I meant is Mecanim cannot animate light parameter or texture UV.
     
  5. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Well, that's awesome news then :) I'll give it a shot soon, thanks
     
  6. dchen05

    dchen05

    Joined:
    Aug 28, 2012
    Posts:
    45
    I thought I would add to this thread with a few things I noticed as well as some questions.

    I have a 2D animation rig that has a bunch of animations. All the animations rotate along the X and Y and never go into the Z axis.
    I have a completelyflat mesh I am importing in the shape of a character with the image applied as the texture. Picture it looks something like Parappa the Rappa.

    I assumed since the animations never go into the Z axis, that the character wouldn't either. But the character twists and turns in a awkward and unpredictable way, Like its not meant to move that way.
    Does unity apply a 3Dness to it?

    Alternatively, would the same thing happen if I imported the character in individual parts instead of one solid mesh?

    $2Davatar.PNG $3dTwist.PNG
     
  7. KAKE

    KAKE

    Joined:
    Apr 5, 2005
    Posts:
    57
    lzitmee, have you had any luck with this approach? I'm curious about this same technique.
     
  8. Pix10

    Pix10

    Joined:
    Jul 21, 2012
    Posts:
    850
    You may have already seen it, but if not it may be worth checking out Smooth Moves in the asset store which is probably more akin to what you're after.
     
  9. KAKE

    KAKE

    Joined:
    Apr 5, 2005
    Posts:
    57
    That's excellent, thanks for the tip!
     
  10. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Hey KAKE, I still didn't try :p I was actually using Smooth Moves, and though it is indeed an awesome asset and I usually recommend it, I'm starting to get a little annoyed by its clumsiness (though I still didn't try the new v2, maybe it's better but I couldn't find a "what's new" list), and hope Mecanim will be able to make the same things in a smoother way. But as Pix10 said, Smooth Moves is really nice anyway.
     
  11. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    P.S. Spine looks very interesting too, though it's an external program which will export stuff for Unity (if the Kickstarter succeeds)
     
    Last edited: Nov 25, 2013
  12. aodry

    aodry

    Joined:
    Apr 7, 2011
    Posts:
    9
    Hi guys,

    I'm working with Animation and currently I am on the GGJ in Netherland. We have a MVN full body motion capture system here, which can record mocap data and export it into fbx. I see that people here at GGJ bit afraid of 3d (time limitation) and many uses 2d stuff.. so now.. I am thinking how to use our sftuff for 2D. I have 17 trackers per system, which can be streamed real time or exported as fbx and imported to unity as mecanim animation.

    so now I found this thread and I think I have some idea which can help you as well.

    so here is one possible solution to use an fbx animation in any transform object:
    1. export anim as fbx (in my case this would be a few sensors like upper body or only head from a full body capture)
    2. set the anim type (in my case humanoid, since the fbx was created for bipad model)
    3. in mecanim editor select the part of animation you want to use and mask all the segments you dont want to use, then save it.
    4. create a character which has the right bipad model (set to humanoid), with the required segments (i.e. only hands and head = 3 sensors). (there is also another way see below)
    5. then use mecanim state-machine to build up the animation you need.
    6. add your char to the scene, attach the right animation state machine and go go go

    Another quick way to get around with some transform problems, if you use a real mecanim char (use one from the demo). You can create it real time or just add to your scene and hide it. you can also create your own skeleton to make it simple. The point is, to use this model as a template transform object. You can map a full body motion to this character and you can update your game objects from code. You just have to read the right segment's transform object (hand, head, etc) from this model. It is very simple and you dont have to deal with masking the animation or transforming rotations. this way the all animation root can be managed from mecanim, I think you get the point.

    I will try this sooon... if I can make it work, then I could animate a face or cloths or a ragdol or any other object in 2d with moving the trackers with my hand... and GGJ could use a bit more of our stuff here..