Search Unity

Smooth Moves - 2D Skeletal Animation

Discussion in 'Assets and Asset Store' started by echo17, Feb 20, 2012.

  1. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    I'm not sure what you mean by segmented animation. Can you explain this?
     
  2. TorontoJoe

    TorontoJoe

    Joined:
    Mar 25, 2012
    Posts:
    32
  3. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Very cool!

    Yep, you are correct. Smooth Moves regenerates itself so that you don't have to manually update before running your scene. It has to completely destroy and recreate the bone hierarchy in case something has been removed or added. It also has to regenerate because for some reason prefabs lose a lot of references that need to be remade at runtime. I've thought about pulling and storing references to foreign objects (objects created by users and attached at design time). One obvious problem with this is what to do with objects that are attached to bones that no longer exist. I'll add it to my list to ponder.

    In the meantime you can create your game objects and place them somewhere else in your scene. At runtime you can attach your gameobjects by first referencing the bone you want to attach to and then setting your gameobject transform's parent to the bone. Something like:

    Code (csharp):
    1.  
    2.  
    3. // inspector references set at design time
    4. public Transform trailTransform;
    5. public BoneAnimation boneAnimation;
    6.  
    7. .
    8. .
    9. .
    10.  
    11. // Somewhere in your code, probably near the start of the animation's life (like the Start method)
    12. // get a bone transform, in this example the left arm
    13. Transform armTransform;
    14. armTransform = boneAnimation.GetBoneTransform("Arm_L");
    15.  
    16. // set the trail transform's parent to the arm bone
    17. trailTransform.parent = armTransform;
    18. trailTransform.localPosition = Vector3.zero;     // or whatever offset you want
    19. trailTransform.localRotation = Quaternion.identity;      // or whatever rotation your want
    20. trailTransform.localScale = Vector3.one;      // or whatever scale you want
    21.  
    22.  
    Hope this helps!
     
    Last edited: Apr 21, 2012
  4. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Hi echo17.

    Just got Smooth Moves, which looks very (VERY) awesome :) I just have a note: an online documentation would be really needed. Going through all the video tutorials (though well done) takes a huge amount of time. And if later you forget something, having a place to quickly go and read descriptions/usage of all features would be a real time-saver, contrary to having to look through the right video.
     
  5. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    This is a terrific suggestion. I had started to create a document, but I've made so many feature updates in the last month or so, the document became out of date very quickly. I think I will wait until a major milestone to try to tackle this again.

    Thanks!
     
  6. runonthespot

    runonthespot

    Joined:
    Sep 29, 2010
    Posts:
    305
    regarding the recreation of the skeleton / hierarchy each time, I had a similar issue where I wanted a projectile to target a specific part of the moving skeleton. Using a blank gameobject, named appropriately works too. Since you can have a blank gameobject in the skeleton, so easily, how hard would it be to introduce a third option, that was just a GameObject variable slot aka prefab reference? Something to ponder for those who might want to attach multiple particle systems to their sprite.
     
  7. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    That is definitely something to ponder. I'll need to think through all the scenarios to be sure it jives with my current model, but it sounds feasible on the surface at least.

    Thanks!
     
  8. TorontoJoe

    TorontoJoe

    Joined:
    Mar 25, 2012
    Posts:
    32
    Great! I did this and it looks awesome. I should have followed the shadow example from the tutorials - which would have solved my problem. Somehow, I wasn't paying attention during that part. My bad.
     
  9. AntFitch

    AntFitch

    Joined:
    Jan 31, 2012
    Posts:
    243
    Sounds like a wiki is needed! :D

    I know it's been discussed before, but I'd like to put in another vote in for a method that allows us to batch our skinned meshes. With an army of 50 slimes, my frame rate is very low on iOS. I saw the link to the MeshMerger script, but at least for me, it doesn't seem to work.

    I know SmoothMoves is supposed to be just for bones animations, but it's such a nice editor and I've found so many ways to customize my animations... it's no wonder your growing army of developers are pestering you for more. You made SmoothMoves too easy to use for all sorts of things we need. :)
     
    Last edited: Apr 24, 2012
  10. helsinki

    helsinki

    Joined:
    Apr 12, 2012
    Posts:
    5
    I think what he meant by segmented is shown below in diagram 2.



    So is it possible for smoothmoves to do skinning like the one shown in diagram 1? Just like in 3d programs.
     
  11. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Yeah, I plan on making some docs when I can come up for air. It's getting harder to balance time between developing, training, and promoting, but I'll eventually circle around to each.

    Actually, this is a Unity limitation. Unity does not batch skinned meshes. I can't say why this is, I'm sure the Unity engineers have some reason for this, but it probably has something to do with the fact that it would require more cpu time to batch than it would actually gain. Here's a thread on this topic:

    http://forum.unity3d.com/threads/88927-Dynamic-batching-%28fbx-object%29

    You may want to put in a vote for this feature to be added here:

    http://feedback.unity3d.com/forums/15792-unity

    Yeah, sorry for it's ease of use :) I definitely do need to re-evaluate the editor now that I see how it is being used. It has shown an emergent usage that I had not originally intended -- that of being a classic sprite animator. There are probably a lot of things that could be done to better accommodate artists preferring to stick with sprite sheets over skeletons.
     
  12. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Ah, thanks for the visual helsinki.

    No, Smooth Moves cannot do the skinning in diagram 1. That would be a true 3D mesh like something produced in 3DS max, Maya, Blender, etc. What Smooth Moves does is create a series of quads (or "segments") that are moved around attached to a skeleton. Each bone can have a texture attached to it. The texture can use transparency to give the illusion that you are working with a 3D object, just with a simplified and highly optimized mesh (dozens of vertices instead of hundreds or thousands). Using a skeleton allows you to smoothly (hence the name) transition between states, giving you an edge over traditional 2D sprite animation which uses a series of images to give the illusion of movement.

    The result is highly stylized and geared toward a 2D feel. Mostly used in cartoony animations, like something you would see in Zombieville or Battleheart.
     
  13. AntFitch

    AntFitch

    Joined:
    Jan 31, 2012
    Posts:
    243
    That's sounds similar to what novelists say when their characters take on a life of their own! :)
     
  14. runonthespot

    runonthespot

    Joined:
    Sep 29, 2010
    Posts:
    305
    I think where SmoothMoves really shows itself is the fact that it does skeletal animation AND sprite animation. If you have an artist who can produce variations of expressions, eyes, etc, you can so easily animate the skeleton and change expressions. It becomes like having tv cartoon production software.
     
  15. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Yep, it seems that process is pretty universal in the creative realm. :)
     
  16. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    I forgot to mention. If you are using the latest version of Smooth Moves (1.7.2), there is a setting in the BoneAnimation class that lets you turn off color processing in the inspector. If your mesh is not using color changes at runtime, you can uncheck this to get a slight boost in processing. Of course, if you are using colors, unchecking this will make them not change at runtime.
     
  17. AntFitch

    AntFitch

    Joined:
    Jan 31, 2012
    Posts:
    243
    I'll give it a shot and see what happens.

    [Update]
    Yup, that helped. FPS hits 30 when I have 60 slimes. Nice!
     
    Last edited: Apr 24, 2012
  18. bananamouth

    bananamouth

    Joined:
    Apr 10, 2012
    Posts:
    6
    Bought it yesterday and been messing around with it for a couple hours while following the tutorials. It looks pretty great so far, good job.

    The only thing I'm missing (and I've noticed some posts about it) is IK controls. Some things would be a lot easier with some kind of IK/FK toggle when animating.
     
  19. dasbin

    dasbin

    Joined:
    Jan 14, 2012
    Posts:
    261
    Thanks for all the help so far, and the great product.
    Just a quick question. Our target platform is iOS and Android.
    What is the most efficient way of doing a very large animated sprite that swaps textures (frames)? In other words, given that the maximum atlas size for mobile is 2048x2048, if we wanted a single 2048x2048 background sprite animation (no bones) to constantly play, is this totally unrealistic? It seems like one would have to swap in a new material every single frame, and the draw calls would be ridiculous / performance horrible. Is there any real way to do this?
     
  20. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Thanks!

    Yeah, IK would be nice. It is on my list to look into, but I haven't put together what all will be required to do this, so a good estimate on when it would be available (or even possible) would be hard to give. I'll definitely keep this status updated as I find time to research this.
     
  21. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    You could certainly do this, but most of your performance hit would not be in swapping the materials (which take almost no time at all), but on the fill rate of such a large texture. Draw calls would only be the number of materials being displayed at once. In the case of your background texture, I assume that would just be one material / texture so you'd only have a single draw call. Filling the entire screen every frame can be expensive on mobile devices, especially if that fill is using a shader with alpha.

    My suggestion would be to try it out and see how much of an impact it has on your game's performance. Since you probably won't have a lot of backgrounds playing at once, the one draw call per skinned mesh limitation won't be a factor here.

    If your animations do not change color at runtime, you can set the Update Colors setting in the BoneAnimation inspector to false. This will give you a bit of a performance boost.
     
  22. TorontoJoe

    TorontoJoe

    Joined:
    Mar 25, 2012
    Posts:
    32
    Any chance we can get a dockable window for both the atlas editor and the animator similar to EasyMotion2d? Also, trimming and rotations in the atlas editor would be magical, actually, trimming is essential in my opinion.
     
  23. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    I had originally had the animation editor as a dockable window, but the clipping forced me to switch to an tool window. What happens when you rotate a GUI element is that Unity clips the image BEFORE it rotates, this leaves you with oddly sheared textures when they are not aligned at zero degrees. To circumvent that, I removed the clipping, but then the textures were being drawn outside of the dockable window's area, leaving a messy and unprofessional look. I settled on using a tool window because it suffers from neither of these problems. I wish I had kept some screenshots to show the effects I am talking about.

    I could certainly look into trimming. Not too sure about rotations, though.
     
  24. TorontoJoe

    TorontoJoe

    Joined:
    Mar 25, 2012
    Posts:
    32
    Awesome. Rotation's not as important but trimming would be great, especially if you use it for spritesheet based animations. I know it's not made for that but I'm sure some people will use it for that too since it's just so damn awesome. I know I do. haha.
     
  25. TorontoJoe

    TorontoJoe

    Joined:
    Mar 25, 2012
    Posts:
    32
    Is there a way to broadcast a message after a certain animation has finished playing?
     
  26. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    You could use a user trigger and then register that in code. This is much more efficient than sending a message since that uses reflection (not good on mobile devices).

    Here's my tutorial on how to set these up:

     
  27. mplaczek

    mplaczek

    Joined:
    Feb 13, 2012
    Posts:
    19
    Hi echo17,

    I'm not sure if you saw or have already been in contact with Samb88. He created a framework called 2D Jump'n'Run. It's a pretty groovy 2D platform framework... I've been using it and Smooth moves for my game... and it seems from his most recent postings, Samb88 is too... he is updating his framework so that it will work with your plugin... That's fantastic news for me, but also a big bonus for both of your frameworks/plugins!

    Horray!!
     
  28. TorontoJoe

    TorontoJoe

    Joined:
    Mar 25, 2012
    Posts:
    32
    Hmmm... I think I phrased the question wrong, what I was hoping to do was chain a number of animations together, so if X animation that occurs for 2.5seconds finishes playing, it notifies you it's done playing then you can designate a method to be called exactly after that 2.5seconds.
     
  29. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Unless I'm missing something, that's what that video shows you. You can just add a user trigger at the end of an animation, capture it, and start another animation.
     
  30. TorontoJoe

    TorontoJoe

    Joined:
    Mar 25, 2012
    Posts:
    32
    Ah I see, thank you for clarifying that. I actually fast forwarded to the middle of the video and assumed this was the collider example video. My bad.
     
  31. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Yeah, sorry about that. I should have explained how to adapt this tutorial to your needs. Thanks, Izitmee for clarifying, and yes, that is exactly how you'd do it. Just add a user trigger at the end of an animation and fire off another animation from your registered callback. Be sure you are on the latest version of Smooth Moves before doing this as there was an issue in previous versions that would give an error if you tried to start an animation from a user trigger.
     
  32. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Thanks mplaczek! I wasn't aware of this so I'll have to check it out for sure.
     
  33. TorontoJoe

    TorontoJoe

    Joined:
    Mar 25, 2012
    Posts:
    32
    Thanks again!
     
  34. SpadeAce

    SpadeAce

    Joined:
    Mar 12, 2012
    Posts:
    7
    Hello,

    When i rotate sprites in bone animation, it becomes pixellated. (Left leg of character)



    Do you have any suggestions?
     
  35. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Nice artwork!

    Hmmmm... that would appear to be something happening between the shader, display ratio, texture filtering, and texture quality, but I couldn't say which is causing the problem specifically.

    Are your animations at the same size as the texture (1:1 ratio between world unit and texture pixel)? Also, is your camera set to orthographic with the size set to half the screen height? These conditions give you a pixel - perfect image, so anything else will probably produce artifacts as the Unity engine tries to fit the pixels into a space not exactly sized to them.

    [EDIT]
    You may also want to check your filtering on the texture. If it is set to point, then you will see some pixelation. Try bilinear and see if that helps out.
    [/EDIT]
     
    Last edited: Apr 30, 2012
  36. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    1.8 preview

    Here is a preview of a couple of features that will be included in the next version of Smooth Moves. It is currently in beta testing, so it shouldn't be too long before it is released to the Asset Store, barring any unforeseen major bugs.

    Local Scale

    Now you can scale a bone and its children at the same time. This can give you all sorts of interesting distortion effects, further making your animations look more organic! A new gizmo is introduced that lets you switch between the image scale and local scale gizmos.





    Bone Visibility

    Show and hide bones in the editor to give you visibility "around" textures in your way. This toggle won't affect what is created in the mesh, only what you see while animating.

     
  37. SpadeAce

    SpadeAce

    Joined:
    Mar 12, 2012
    Posts:
    7
    Thank you.

    I solved the problem by changing filter mode of atlas from point to bilinear.
     
  38. TorontoJoe

    TorontoJoe

    Joined:
    Mar 25, 2012
    Posts:
    32
    Awesome! Can't wait for Bone Visibility.
     
  39. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    And me I can't wait for local scale! :) I'm so happy with Smooth Moves already.
     
  40. TorontoJoe

    TorontoJoe

    Joined:
    Mar 25, 2012
    Posts:
    32
    I agree. I bought the other package that did skeletal animation too but I just keep coming back to this because it's just so good.

    I'd love to be able to insert keyframes in-between existing ones or be able to drag and move a whole selected group then it'd be perfect. :D
     
  41. Mars91

    Mars91

    Joined:
    Mar 6, 2012
    Posts:
    572
    If I'm working on two PC can I export and then import my animation?
     
  42. TorontoJoe

    TorontoJoe

    Joined:
    Mar 25, 2012
    Posts:
    32
    I do this too. I import and export my animations with Unity's export/import package feature.
     
  43. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    TorontoJoe is correct. If you use Unity's "Asset->Export" and "Asset->Import Custom Package" you will be able to move your animations around. Be sure to package your atlases, materials, atlas textures, and animations together. Unity's package will keep all the links intact so you won't need to remap anything.
     
  44. SpadeAce

    SpadeAce

    Joined:
    Mar 12, 2012
    Posts:
    7
    I agree.

    Also, every time you get atlasses from asset server you have to rebuild all atlasses one by one. Is it possible to add a rebuild all atlasses option?
     
  45. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Hmmm... that's strange. I haven't used asset server, so I'm not sure what might be happening here. It sounds like it isn't keeping the GUID's intact like a package would. I'll look into a rebuild all option.
     
  46. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    I submitted 1.8.0 to the asset store today, so hopefully it will be available soon. I will let you know when Unity has approved the update.
     
  47. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    That was super fast! Unity has approved the 1.8.0 update.

    Bug Fixes:
    - Optimizations in editor to improve refresh rate when many animation clips exist.
    - Image scaling will now work when mixing.
    - Fixed refreshing after Undo.

    Features:
    - Added a bone visibility toggle to show / hide bones in the animation editor.
    - Added Local Scale property to each keyframe. This differs from the image scale in that it will scale all child bones as well.
    - Added local scale / image scale gizmo toggle to switch scale gizmos between the two types of scales
    - Put a zero degree line in the rotation gizmo to better see the angle.
    - Changed alternate contrast to be lighter background and darker gizmos.
    - Zooming in the animation editor window will now center around the mouse, not the origin.
    - Improved selection bounds detection when clicking on bones in animation editor window.
    - Changed "Update Colors" setting in BoneAnimation to be false by default for better performance. If you want colors to be updated at runtime, you will need to manually set this to true either in the inspector at design time or in code at runtime.
    - Changed max atlas size selection from a free entry integer field to a drop down list that matches Unity's texture inspector max size list.

    Head on over to the asset store to pick it up!
     
  48. SpadeAce

    SpadeAce

    Joined:
    Mar 12, 2012
    Posts:
    7
    It looks perfect!


    @Echo17,

    I have stand and attack animations in a bone animation and a bone named "Slash" which is used for only attack animation. In stand animation, i made it,
    - transform only
    - 0% alpha
    - 100% blend
    in the first and the last keyframes to make invisible.

    In animation editor everything is working correctly.

    On code,

    while (CurrentStatus == CharacterStatus.Attacking)
    {
    Character.CrossFade("Attack");
    Character.CrossFadeQueued("Stand");

    yield return new WaitForSeconds(3f);

    }

    I have something like that.

    My main aim is after attack animation complated changing character animation to stand and after 3 seconds making character attack again.

    However, when it starts Stand animation after attack, "Slash" bone becomes visible until it plays attack animation.

    Do you have any suggestion?
     
  49. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Hey SpadeAce,

    I think I will need to see your animation to give you a better assessment of what is going on. Shoot me an email at support@echo17.com and we can work out the details.
     
  50. benherrera

    benherrera

    Joined:
    May 4, 2012
    Posts:
    1
    Hi,

    How's it goin? Hey, quick question about the SM animation editor...I'm working through the demo and whenever I create the bone hierarchy, attach an image to each bone, then press the pivot adjust button Unity freezes up on me and I can't do anything. Is there a way to fix that? The demo works fine until I reach that point then instant freeze.

    I've deleted the Smooth Moves folder from the project area and re-imported but it still won't work.

    Thanks for your help,

    b-