Search Unity

Smooth Moves - 2D Skeletal Animation

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

  1. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    if you use ngui for just top layer and use 2 cameras it is ok. if you use different layers like A(NGUI)->B(SM)->C(NGUI), and you have 2 atlasses (NGUI,SM) and your layers overlaps/masks others you have problem. unity draws A and C then B. one draw call for one atlas. if there is no problem with sm and unity animation integration i can use for all animation and background assets with sm and ngui just for gui layer.
     
  2. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    I guess I'm not understanding why you would have two GUI layers, especially one behind the scene. Seems like all GUI, by definition, should be on the top layer. A GUI layer in the background would have problems with objects from the scene getting in the way. Your users would not be able to interact with the GUI if scene objects happen to be occluding the scene. Of course, that may be the design of the game, but I've never seen that before.

    If you are just wanting a non-interactive background, then you should probably be using sprites (2DTK, ex2D, SM2, etc, or even Smooth Moves).
     
  3. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    i need gui. i also need sprites as game actor.

    i can use SM for sprites but i want also use unity animation feature. there will be no interaction on most of these sprites but i want to move them. imagine that; at bottom there is an sky background. then there is a boat on this sky. then there is a sea. boat will move/rotate and it will seem like it sinks the sea. i know i can use SM's animation. but i want to see all together and set animations.
     
  4. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    I would recommend using 2DTK or ex2D or SM2 for the background sprites, then. nGUI shouldn't be used in the background, only the foreground for GUI elements.

    This way your layers would be:

    1) Background: 2DTK, ex2D, SM2, or other sprite plugins
    2) Middle: Smooth Moves
    3) Foreground / GUI: nGUI
     
  5. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    sometimes it is not possible. assume that you have 2 mountain layers (close and far). i make a bird with SM bone animation. i want it to fly between these mountain layers. close mountain must mask the bird. i mean bird sometimes disappears because of close mountain.

    can you try this case? for mountains there is one atlas on 2dtk/ex2d and one atlas for bird on SM. this is my problem.
     
  6. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    I guess I am not understanding why you are putting mountains in the GUI, and not using sprites. nGUI should be used for GUI (Graphical User Interface), meaning buttons, input boxes, sliders, etc -- things the user can interact with. Mountains and all other sprite objects should be done with a sprite package.

    [EDIT]

    Also, be sure that you are using shaders that have a depth sorting. That is one reason why I use the alpha blended shader -- it will render elements in the correct depth order.

    [/EDIT]
     
    Last edited: Aug 10, 2012
  7. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    to use sprite i have 2 options; SM and NGUI. SM does not have unity animation support but NGUI has. i do not intent to use gui for background images.i had to use ngui for this purposes because it is the only package i have that has unity animation support. i dont have neither ex2d nor 2dtk.

    if you add support to use SM sprites (not bone animations) with unity animation system i will have no problem :) then i will use SM for all layers and on the top i will use NGUI just for GUI purposes.

    i will also check shader. maybe it will solve my problem.
     
  8. Sytto

    Sytto

    Joined:
    Jul 20, 2010
    Posts:
    28
    I'm doing tests with the new function "SwapTexture", this functions seems to be very slow and eventually it won't work if I "spam" it ( I have some kind of character editor ) by clicking texture buttons that triggers the function.

    Is this normal?
     
  9. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    can you add support for unity animation for your sprites? now i changed all layers to SM sprites. it is not easy to animate some actors without seeing whole picture.
     
  10. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Without seeing your full project, it would be hard to guess what is going on. If you can send me your zipped up project, I'll take a look.

    support@echo17.com
     
  11. Sytto

    Sytto

    Joined:
    Jul 20, 2010
    Posts:
    28
    Hi again, at the moment I'm fine with the old functions, also I ran other tests in different scene and I hadn't problems, but I have another question.

    When I use AttachTransform my objects appear always on top of all bones, even if some bone has lower depth or different Z value. e.g I wanna be able to put body-attached items under head bone (I'm able to put one item under other item but NOT one item under one bone) I think this could be fixed with a shader (I have no idea about shaders) because it works fine when i use Unlit/Transparent Cutout shader but that shader has that ugly cutout effect. Any approaching to do this?
     
  12. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    The depth of the bones doesn't control the transform z position. Rather, it controls the order that the quads are drawn in the mesh. In order to have an object be behind a bone, you'll need to shift that child object's z position along the z axis (forward or backward, depending on the rotation of your bone animation). Be sure you set the z position after you attach to the bone, and not before.

    Keep in mind that if you do this, you won't be able to rotate the animation along the y axis to make it point in different directions. Instead, you'll need to set the x scale of the bone animation to -1.0f or 1.0f depending on the orientation desired. That way the child object will remain behind the bones as intended.

    Also, if the child object continues to appear in front, it may be that you are using a projection camera (instead of ortho). That can cause weird sorting issues at the edge of the screen. You may need to switch to an ortho camera to ensure that the z positions are sorted properly. If you still need perspective for a parallax effect on the foreground / background, then you can have a second camera in perspective mode that sits on top of your ortho camera and only renders those elements that need parallax.
     
    Last edited: Aug 15, 2012
  13. Sytto

    Sytto

    Joined:
    Jul 20, 2010
    Posts:
    28
    I'm afraid I do not understand. Right now my transforms (items) are attached with localPosition.z = -1.0f to appear on top of it's bone, for flip animations I set the x scale of my character to -1.0f or 1.0f ( I think this is what you said ), my camera is orthographic, could you give me a little example ?
     
  14. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Sure, check out this stripped down version of the knight code from the demo. I've commented all the relevant sections (the attachment of the object and the scaling of the knight when he switches direction:

    Knight_AttachChild.cs

    Here are some images of the design time and run time, showing the position of the child object (in this case a head), being attached to the knight's hand. You can see the child is behind the knight's hand, whether he is facing left or right due to the scaling of x.

     
  15. Sytto

    Sytto

    Joined:
    Jul 20, 2010
    Posts:
    28
    thank you very much!
     
  16. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Keep in mind this method will put the child object behind all the other bones, not just the one it is attached to. You can see in the above screenshot that the head is behind the arm and sword as well as the hand.

    If you want to have your child somewhere "sandwiched" between bones, then you'll need to create another bone in your animation at that depth. You can then switch out or hide the texture using the SwapTexture functions. This method doesn't require that you attach children at runtime.
     
  17. Sytto

    Sytto

    Joined:
    Jul 20, 2010
    Posts:
    28
    yes I just realized :p it seems that I will need to have extra bones for have this kind of sandwiched items
     
  18. cynel

    cynel

    Joined:
    Apr 18, 2012
    Posts:
    734
    with this i could create flashback cut scenes for my project with out buying pro
     
  19. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Yes, you could animate scenes with Smooth Moves. It works on both the Indy and Pro licenses. All the tutorials and the demo scenes (including the iPad video on the first post of this thread) were done using the Indy version of Unity.
     
  20. cynel

    cynel

    Joined:
    Apr 18, 2012
    Posts:
    734
    alright is it possible to make color the 2d models in shadow to make my flash back cut scene
     
  21. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Yes, you can change colors on your animations in three ways:

    1) At the mesh level (good for faking scene lighting)
    2) At the bone level (good for varying the color of individual parts, like clothes or skin)
    3) At the keyframe level (good for animating color, like glowing objects, flashing, etc)

    Have a look at my user manual, specifically Chapter 7, Section 5.5, Section 5.8 (color), and Section 5.11 (mesh color):
    User Manual
     
    Last edited: Aug 16, 2012
  22. cynel

    cynel

    Joined:
    Apr 18, 2012
    Posts:
    734
    good i want to make the flashback cut scenes look like shadow puppet animation
     
  23. dasbin

    dasbin

    Joined:
    Jan 14, 2012
    Posts:
    261
    Hi Echo,

    I have a little bug report.
    I use a script to disable the entire GameObject on which the BoneAnimation is present if it is outside of a certain range, for performance reasons (not rendering-related... there are a bunch of calculations also running on these objects).

    The _SmoothMoves_Manager GameObject doesn't like it when this happens. In the editor, the manager will not destroy properly itself after stopping playing. Then errors start popping up in the console. After a couple rounds of play/stop, several instances of the "_SmoothMoves_Manager" object exist in the hierarchy and they are all spewing constant errors.
    I'm not yet sure how this affects an actual build; just testing in the editor so far.

    I realize the immediate advice is probably "don't disable the objects," but this is by far the most convenient way to achieve several things at once for me. If it is too difficult for you to fix the problem, then I'll have to look into how to do that, but for now, I thought I'd rather ask on here if you could possibly write a trap into your code for a) when a BoneAnimation GameObject is disabled and b) to make sure more than one _SmoothMoves_Manager never exists in the hierarchy. Thanks for your time.
     
    Last edited: Aug 17, 2012
  24. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Hmmmm...I can't seem to replicate this bug. When I call SetActiveRecursively(false) on my boneanimation's gameobject, the object hides and no errors are output. Only one instance of the manager continues to run.

    My guess is that there is something very specific about your setup or the timing of your call that is causing Smooth Moves to hiccup. If you could send me a zipped package of your project (water it down as much as you need to), I can take a look and see exactly what is causing the problem.

    You can email to support@echo17.com
     
  25. dasbin

    dasbin

    Joined:
    Jan 14, 2012
    Posts:
    261
    Thanks for your help.
    It's actually looking more and more like this is actually an issue with PlayMaker (which I use to deactive the GameObject), so you're probably right. Sorry for the false alarm. If I manage to track it down a bit further I'll post back.
     
  26. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    No prob. I've tried to make the manager so that it won't try to instantiate more than a single copy of itself. The fact that it's doing that for you means there is probably a bug in there somewhere. Let me know what you find out. I'd be happy to get a patch out to you (and release it in my next service release as well).
     
  27. cynel

    cynel

    Joined:
    Apr 18, 2012
    Posts:
    734
    well my game is in pre-production so when i get storyboards together i will buy your smooth moves and start animating
     
  28. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Is it possible to export the frames of an animation as a .jpg or .png or the animation itself as .gif ?
     
  29. mikael_dk

    mikael_dk

    Joined:
    Aug 18, 2012
    Posts:
    10
    Is it possible to switch bone animations at runtime on a game object?

    What I want is to have two different bone structures when animating a character (one bone structure to animate left/right + one for front animations).

    But since I cannot have different bone structures on the animations within the same bone animation then I guess I will have to switch the bone animation at runtime (using C#) ?

    Besides this question I also want to thank you for releasing this great product.
     
    Last edited: Aug 18, 2012
  30. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    No, I'm afraid I don't have that ability yet. I believe KenWong did this process manually by setting the time in the editor and taking screenshots to get his highkick animation

    kenwong's "highkick"
     
    Last edited: Aug 19, 2012
  31. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    You are most welcome. It has been a personal joy coding it.

    Yep, you could attached two (or more) bone animations to a gameobject and then switch them on or off in your logic depending on which way the character faces. I was actually thinking about doing this in my next game project (when I find the time :) ) I want to have a character that moves around in 2.5 dimensions, using front-facing, back-facing, and side-facing animations that I switch through. The different animations have different bones, so this method would definitely be the way to go.

    You could also create one animation with extra bones and then just not use the extra bones in some of the animations. This is wasteful, though since you'd have a lot of empty data just taking up memory. The switching would be a more elegant and resourceful solution. If you have just a couple of extra bones, however, this might be an easier way to go.
     
  32. danboutros

    danboutros

    Joined:
    Mar 26, 2012
    Posts:
    32
    Hi there Echo.

    Firstly, I LOVE this tool!

    Secondly, I have a question and a request:

    QUESTION : HOW DO I ANIMATE VISIBILITY OF BONES IN SMOOTH MOVES?

    A - ?

    REQUEST : Can you please create a feature so I can drag and pull limbs like something rigged with IK? For example, let's say I need to drag a THIGH joint to bend lower, but I don't wish to move the FOOT and re-jig everything around.

    I would like that THIGH, when pulled downward, to be constricted in movement by the entire upper body unless I explicitly allow it as such (a toggle?). I find it creates a lot of work when I attempt fixes like this otherwise, as the joints easily detach from one another and create a lot more animation work for me.


    Otherwise, I adore the tool. We'll be making sure to specifically credit the tool in our game, along with the others we use. :)
     
  33. echo17

    echo17

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

    To animate hiding a bone, set its keyframe type to transform only. To show it, set its keyframe type to image. You can also hide and show bones programmatically at runtime by calling the function HideBone in the BoneAnimation script.

    I have IK down on my list of items TODO. It may be a while for this to be implemented since my list is very long.

    Thanks again!
     
  34. Guy77

    Guy77

    Joined:
    Jul 30, 2012
    Posts:
    23
    I have read on here that if i want to rotate a bone with code that i have to delete the second key frame of the animation and then i could rotate that bone from code, the only problem is if i delete the second key frame then the sprite that represents that bone disappears when i play it.
    Sorry if this is a noob question but hopefully i wont have to create a separate gameobject and add a sprite to that and manually attach it to where the missing sprite is.
     
  35. Guy77

    Guy77

    Joined:
    Jul 30, 2012
    Posts:
    23
    Never mind i know what i did wrong, i deleted the end of 3 key frames but forgot to delete one that was in the middle and that was causing the issue, a simple noob mistake.
    Thanks for the wonderful product can't wait to become more efficient at it.
     
  36. hafizmrozlan

    hafizmrozlan

    Joined:
    Jun 15, 2012
    Posts:
    117
    Hey, anyone have any suggestion on what is the best texture size to use from Photoshop file for iOS game development?

    Currently I use relative size like if the character is half landscape screen height then I made it 320px tall. When I import it into smooth moves texture I scale it down by 0.01 factor so it's more realistic in comparison with unity native cube. Maybe if I need to use physic it'll be more realistic then.

    My problem is the texture seems quite blocky and the outline is quite jagged. I don't know if it is just in the editor because my laptop resolution is not as dense as an iPhone, maybe because of that it can't simulate the image exactly, I haven't tested it on iPhone yet (I haven't registered)

    I'm using the alpha cutout shader, because normal unlit alpha shader make some strange white outline and noise visible.

    I don't know how to prepare a clean asset from Photoshop. It looks fine inside Photoshop though. Can anyone share some advice?
     
  37. Hutt

    Hutt

    Joined:
    Aug 20, 2012
    Posts:
    4
    Hye Echo.

    I'm a french video game animator, using you're usefull tool SmoothMoves.
    I've a questions about animation curve. I'd like to use the same curve for different bone but it seems that i can't juste copy paste the curvrs.
    Is there a solution to my problem ?
    Thanks.
     
  38. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Glad you figured it out. I would have had to see your project to determine that issue. Happy animating!
     
  39. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Check your texture settings in the Unity inspector. You may need to change your filtering to "Point" to get rid of the fuzziness. Also, check your compression as that can lead to fuzziness as well.

    As for the white border around the sprite, take a look at these links that describe how to get rid of that:

    http://forum.unity3d.com/threads/60508-Photoshop-Files-Give-White-Outline-on-Transparent-Textures
    http://www.youtube.com/watch?v=mV0pSQGC0hs
     
  40. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    I currently don't have a way to copy and paste animation curves. That sounds like a useful feature, so I'll add it to my list. Thanks!
     
  41. ozma87

    ozma87

    Joined:
    Aug 22, 2012
    Posts:
    17
    Hello echo17, and thank you for this great plugin, it's very useful!

    I have a problem right now with Smooth Moves. The problem is that i've changed the location of the folder where I have all the files from my animation (pieces of the body, animation data, and atlas data) .

    Now, when I open the Animation files, I have to reselect in every frame of every piece of the body, the atlas again. The problem is that the atlas it' s now empty and the only way to make it work it's by redoing it with the same spacing (that I don't remember) and edit every frame of all the pieces.

    Is there a way to solve this? I've tried by changing the folder location to it's original place but it doesn't works...

    Thank you!
     
  42. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Unity has a pretty clever database system built in that keeps track of the files in your project. Whenever you rename or move your files WITHIN Unity, it will update its database to reflect the changes. If you try to rename or move files outside of Unity, like in your OS's operating system, you will break the connections that Unity keeps track of. Smooth Moves relies on Unity's database to keep track of connections, so any renaming or moving should be done within the Unity editor.

    My suggestion would be to use the most recent backup of your work before you changed the location of the folder. After you do that, you can move the folder within Unity and everything should work from there.
     
  43. runonthespot

    runonthespot

    Joined:
    Sep 29, 2010
    Posts:
    305
    ..or turn on .meta files and it handles you moving things around, as long as you move the associated .meta file with it.
     
  44. kenwong

    kenwong

    Joined:
    Jan 22, 2012
    Posts:
    24
    An iPhone4 screen is 960x640 pixels. If your character doesn't scale or rotate, and your camera and sprite are set to be pixel-perfect, then yes, a character exactly half the height of a landscape screen should be 320pixels tall. However if you're planning on doing any scaling or rotating, ideally you'd make your actual character 1.5x - 2x larger, so that the downsampling looks better.

    As suggested by echo17, you may want to turn compression off. The compression algorithms are designed for images that have a lot of detail and gradients, like photos or painted textures. Simple flat areas, like a cartoon or a simple icon actually make the compression artifacts very visible. If you're not using too many colors, 16-bit color might be your best option.

    It's strongly suggested you use the Mobile/Particles/Alpha-Blended shader, it should be faster than cutout on iPhone.

    If you haven't found out already, here's the reason you're finding a white outline around your sprite. If you save an image as a PNG or other premultiplied alpha file, Unity will actually treat 'transparent' pixels as white. A 50% transparent pixel is still 50% transparent, but it's color will be tinted 50% white. To avoid this, use a PSD or TGA file, with a separate alpha channel. You will have the same problem with any pixel that is semitransparent - but the trick is to make sure the 'matte' color of your image matches the solid object. So if your sprite was a red helmet, make sure the background color is red too. If it has a black outline around it, then that's where the semitransparent pixels will be, so make the background (or at least the pixels around the outline) black too.

    So basically... do the 'dilate' thing described here:
    http://docs.unity3d.com/Documentation/Manual/HOWTO-alphamaps.html
     
  45. kenwong

    kenwong

    Joined:
    Jan 22, 2012
    Posts:
    24
    Hey Echo,

    Did you change the way TextureSearchReplace searches, recently? I upgraded SmoothMoves and now my replaces don't work. I'm using it for blinking (I know I can/should be using a blend animation, but go with me here). I search for the idle face and replace it with the blink face. 0.1 seconds later, I do another TextureSearchReplace, for the blink face, replacing it with the idle face. This used to work, but now it doesn't. It looks like the search now looks at the original animation data, not the current state. So I replace idle->blink, then idle->dead, and it works. But I can't do idle->blink, idle->idle.

    Can you reproduce this? And if so, is there a way to do a replace, then replace back to the original? I'm also using this to change the number on my character's shirt to a mirrored version when the character is flipped. That's also not working.

    thanks,
    -Ken
     
  46. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    The search and replace should work as normal. The process always looked at the original texture for searching, no matter what the current state was. This cuts down on the states you have to set up for.

    I did add a few functions to help with restoring the original texture: RestoreBoneTexture, RestoreAnimationBoneTexture, and a variation of RestoreAnimationBoneTexture. These set your texture back to what it was before you did your search and replace.

    I also added some functions to swap out textures programmatically without having to set up the search/replace components. These are the Swapxxxxx functions at the bottom of the API docs located here.

    So for your project instead of replace idle->idle, just do a Restorexxxx and that should fix your problem. You might also look into the swap functions since they are a little friendlier to use, albeit they exist in code and not the editor.
     
  47. danboutros

    danboutros

    Joined:
    Mar 26, 2012
    Posts:
    32
    Hello again Mr Echo!

    TEXTURE DISTORTIONS IN TEXTURE ATLAS BUG?

    We have found a VERY bizarre issue where upon creating a texture atlas of 1024x1024, or even 512x512, we find the textures within, although very neatly organized, are truncated on their right hand side. The smaller the atlas, the more truncated these textures become.

    HOWEVER, when we process an Atlas at 2048x2048, the textures come out fine and everything looks great.

    Do you know if we're missing something here, or if this is a bug?

    Kind regards,


    Dan Boutros
     
  48. dasbin

    dasbin

    Joined:
    Jan 14, 2012
    Posts:
    261
    I don't believe that's a bug. If you set the "Max atlas size" to less than the size of all your textures combined in it, they will be cut off.
    Two possible solutions:

    - Down-res the original sprites or the imported files in Unity before building the atlas.
    - Or, build the atlas at 2048x2048 (or whatever you need), then downres the resulting file with Unity's import manager.
     
  49. kenwong

    kenwong

    Joined:
    Jan 22, 2012
    Posts:
    24
    Ah, that's even better! Thanks for the new functions.
     
  50. kenwong

    kenwong

    Joined:
    Jan 22, 2012
    Posts:
    24
    @danboutros:

    I have that problem too. The texture being truncated is Unity's way of letting you know that your textures are too big too be packed. However, I've found that textures get truncated even when there is clearly enough space, suggesting there's a problem with the algorithm. I'm not sure of the exact case, but it's something like if you have more than one texture which is more than 3/4 the width of your atlas. Eg. I have a 2048x2048 atlas which included one 1546x711 texture. When I try to add a 1536x36 texture it causes atlas to break, but if I make it less than 1536 pixels wide, it works! Atlases seem to pack best if you have lots of small textures.

    Note this is a Unity bug, not smooth moves.