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 don't currently have a tutorial on touch input with Smooth Moves since the plugin is primarily an animation editor. Someday I'd like to have a complete working mini game to show how to integrate it into a working project, but that may be a ways down the road.
     
  2. blaze

    blaze

    Joined:
    Dec 21, 2011
    Posts:
    211
    How is the best way to turn the demo Knight left and right?
    if (Input.GetKeyDown(KeyCode.RightArrow))
    {
    TURN_RIGHT();
    knight["Walk"].speed = 1.0f;
    knight.CrossFade("Walk");
    }

    What is the best way to do that?
     
  3. blaze

    blaze

    Joined:
    Dec 21, 2011
    Posts:
    211
    Solved, but this is the correct way?

    if (Input.GetKeyDown(KeyCode.RightArrow))
    {
    knight["Walk"].speed = 1.0f;
    gameObject.transform.localScale = new Vector3(1,1,1);
    knight.CrossFade("Walk");
    }

    if (Input.GetKeyDown(KeyCode.LeftArrow))
    {
    knight["Walk"].speed = -1.0f;
    gameObject.transform.localScale = new Vector3(-1,1,1);
    knight.CrossFade("Walk");
    }
     
  4. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    That would have been the way I recommended. You could also equally use a local rotation and set the euler angle of the y axis to 180.0f when facing left. Since smooth moves uses the depth to order the quads in the skinned mesh it will render correctly even when rotated.
     
    Last edited: May 24, 2012
  5. Deleted User

    Deleted User

    Guest

    Hi.
    I have been using this plugin for a while and I am quite happy with it.
    However, recently I have noticed in one problem that is bothering me. In my scene I am instantiating some characters and I have noticed that even in the desktop(editor) and iOS/Android, the instantiation of a simple character with takes a hell of time like 0.5s (desktop) to 2 secs (on mobile). The generated atlas is 1024x1024 and the instantiated object has nothing else but the default components such as BoneAnimation. I have confirmed in Unity Profiler that 90% of the Instantiation time is taken inside BoneAnimation.Awake.
    Is there any special reason why there is such heavy initialization in BoneAnimation that cannot be previously pre-computed and prefabed so that when instantiated it runs much faster?

    Regards
     
  6. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    The mesh and animation are created in the Awake function for two reasons:

    1) This eliminates the need to manually create the mesh after making changes in the editor. I could call this from the inspector, but at least one animation would have to be selected. If you just opened the scene and clicked run without first selecting an animation, then these components would not get generated. Not a huge deal, but that kind of inconsistency can lead to confusion.

    2) For some reason when you place an animated character on a prefab, it does not store the animation clips. I've submitted a bug to Unity, but it has largely gone ignored. For any animations created from a prefab I have to generate the animation data at runtime.

    I've been looking at alternatives to building the mesh and animation at runtime, it was actually how I had it originally until I ran into the two problems outlined above. Hopefully I can come up with another compromise that doesn't eat into the initialization time so heavily.
     
  7. HappyGiant

    HappyGiant

    Joined:
    May 24, 2012
    Posts:
    1
    Smooth Moves looks awesome. We actually just spent awhile developing something in Maya that can be passed to Unity (wish I knew about this first!). I had one question. Am I correct in thinking Smooth Moves is a straight FK rig only? Meaning, you move the hand, the arm moves, etc. and have to fiddle with other parts to get the hand where you want it to be. Whereas what we have in Maya, we can place a hand anywhere independently still. Thanks for your answer. --Mike
     
  8. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Yes, currently Smooth Moves is FK only. I have it on my list to look into IK, but it may be awhile coming.
     
  9. robin_notts

    robin_notts

    Joined:
    Apr 7, 2010
    Posts:
    86
    Is there a simple way to attach another gameObject to a bone that isn't lost when you rebuild animation etc? *pesky deadline is looming*
     
  10. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Sure thing. In your code, perhaps the Start function (not the Awake since that is where the mesh is generated) you could attach your object to a bone. Perhaps something like this:

    Code (csharp):
    1.  
    2.  
    3. public BoneAnimation boneAnimation;
    4. public Transform childTransform;
    5.  
    6. void Start()
    7. {
    8.   // Attach child object to the left arm bone in boneAnimation
    9.   childTransform.parent = boneAnimation.GetBoneTransform("Arm_L");
    10.   childTransform.localPosition = Vector3.zero;
    11.   childTransform.localRotation = Quaternion.identity;
    12.   childTransform.localScale = Vector3.one;
    13. }
    14.  
    15.  
     
  11. huxley

    huxley

    Joined:
    Apr 27, 2009
    Posts:
    334
    I would have to second (or maybe third) the request for a IK solution. This would be helpful with 99% of the animations that we are doing with smoothmoves.
     
  12. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Sounds good. My highest priority right now is to get 1.9 released. After that I'm going to go through and document the editor, maybe update some training videos to reflect all the features that have been added over the last couple of months. After I catch my breath from that I'll take a look at the IK and see how feasible it would be.

    Thanks for your patience!
     
  13. robin_notts

    robin_notts

    Joined:
    Apr 7, 2010
    Posts:
    86
    Thanks for the help. Worked well. Deadline met things are looking good. Great tool. When I've got more time/energy my memory is working again I'll report back things I've noticed other suggestions.
     
  14. sanjodev

    sanjodev

    Joined:
    May 29, 2012
    Posts:
    63
    I'm trying to set up some ragdoll on Smooth Moves generated bones. I know you shouldnt modify the bones or add any components to the root bone and everything under it. Instead I tried dynamically adding the ragdoll components in a seperate script. The component in particular a the CharacterJoint. I added a collider in the animation editor, so that it adds a rigid body component as well. I also enabled the Rigidbody components "useGravity", and disabled "isKinematic" flag. The end result, is that Smooth Moves seems be ignoring these flags and just processing the animation. Is there a way to stop Smooth Moves from animating the model? I tried call the Stop() function on the animation object.

    Anyways I just wanted to see if anyone has tried adding Ragdoll on a Smooth Moves generated object and can tell me if its possible, and give some direction, or can confidently say its not possibly yet. In the mean time, I'll still trying out some other random things I can think of.
     
  15. delstrega

    delstrega

    Joined:
    Apr 22, 2012
    Posts:
    14
    Thanks to the Asset Store Madness I finally decided to give Smooth Moves a try and all I can say is that I'm really amazed.
    Great work echo17! :)

    There's 2 things which kinda bother me though:
    1. If I click on "pivot" in the Bone Animation Editor it freezes up Unity so that I have to close it and open it again. If I click on "pivot" in the Atlas Editor, it works normally.
    2. Call me stupid but I can't find an "Undo"-feature in the Animation Editor. A simple undo would be so helpful! It's kinda annoying when I try to fiddle with my animation and mess it up in the process with no way to go back. Having to write down the old values before editing them seems to be the only way for me.

    On a sidenote: Would it be possible to add the feature to show a reference image (or several) in the background of the Bone Animation Editor? I'm trying to "port" my old sprite sheet animations to Bone Animations and the old sprite sheet as a reference would be very helpful there. I guess I'm not the only one who would appreciate such a feature.

    EDIT:
    I sent a small example project with the pivot crash problem to support@echo17.com.
     
    Last edited: May 29, 2012
  16. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    If you want to not play the animation on start, you can uncheck the "Play Automatically" box on the Animation component.

    I haven't tried a ragdoll in Smooth Moves mainly because I figured it would rotate bones in three dimensions, instead of confining the quads to the 2D plane. This might make the bones look a bit odd, but again, I haven't actually tried it. I'd be interested in anyone's experience with this as well.
     
  17. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Awesome, thanks!

    Yeah, this is a known bug that will be fixed in the upcoming 1.9 release. This release is still in beta, but should be ready soon.

    You can call undo with the keyboard shortcut Ctrl+Z.

    Yep, I have this on my list. It's actually something I've wanted for my own animating as well.
     
  18. delstrega

    delstrega

    Joined:
    Apr 22, 2012
    Posts:
    14
    That's some great news, echo17! At least I'm not the only one experiencing that pivot thing ;)
    Oddly enough, when I tried using the standard "Ctrl + Z" before it didnt work. I just tried it again now and realized I had to press "Ctrl+Z" twice for some reason Well at least it works now :D

    Thanks again for the quick reply - I'm really looking forward to that reference image stuff!
     
  19. robin_notts

    robin_notts

    Joined:
    Apr 7, 2010
    Posts:
    86
    Something I've noticed is that if you drag the animation window partially off the screen and then back on again this can occur:

    It's not a big deal but scared me the first time it occured.

    Does Smoothmoves always save the animation as you go? It currently feels a little unsafe and it would be good if you could SaveAs.. to make another copy. Occasionally I lost some animation work (even after closing the animation window), possibly because of a crash in Unity.

    What exactly is the tickbox button for at the top of the animation window for? I use it to update an animation in a open scene, is that correct?

    Is there any documentation about how all the Mix/Blend/Layer stuff works?

    Thanks.
     
  20. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Hmmm...haven't seen this before. I'll take a look and see what might be causing it.

    Yes, any time you make a change it will update the Bone Animation Data asset automatically. You could back up your animation by selecting the asset and Duplicating through the edit menu.

    It is used to immediately update all instances of the mesh in a scene. This is useful if you want to see what the mesh would look like in your scene without pressing the Play button. Keep in mind that Smooth Moves will automatically regenerate the mesh to reflect the animation data when you play a scene, so this button is optional.

    This is just Unity's animation system being used, so here are some links to their documentation. There's probably dozens of threads on the subject in the forum as well.

    http://unity3d.com/support/documentation/Manual/Character-Animation.html
    http://unity3d.com/support/documentation/Manual/Animation%20Scripting
     
  21. sanjodev

    sanjodev

    Joined:
    May 29, 2012
    Posts:
    63
    I was thinking that you can use the flags on the Rigidbody object to constrain rotation in certain dimensions to overcome this.
     
  22. hidekihanida

    hidekihanida

    Joined:
    May 30, 2012
    Posts:
    5
    I often use UserTrigger.
    And I want to set some UserTrigger properties like String and Int to call function.
     
  23. delstrega

    delstrega

    Joined:
    Apr 22, 2012
    Posts:
    14
    Hi echo17!

    I'm currently using your Smooth Moves Playmaker Actions and stumbled upon something a little annoying:

    SmoothMoves_PlayAnimation with a looping animation NEVER finishes, meaning you need another action to actually switch the state. (Just like in your tutorial where you check for KeyUp and exit the state when this event occurs)

    Since I use it to play a Die-animation, reset the player and then just want to play the regular idle animation again (which obviously loops) I had to add
    Code (csharp):
    1.  
    2. if(anim.wrapMode == WrapMode.Loop){
    3.    Finish();
    4. }
    5.  
    at the end of OnEnter. I know that the way SmoothMoves_PlayAnimation is designed allows one to do stuff exactly when an animation finishes but that's not much help for animations which actually never finish on their own. I just wanted to let you know that it might be a good idea to incorporated a bool flag or something to let it Finish() immediately after starting the looping animation.
    That might be more convenient for some situations.
     
  24. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Since the user triggers are always fired at the exact same point in the animation, you could reference the bone and frame where the trigger occurs and perform your logic from there without needing to pass values. Have a look at the user trigger tutorial:

    http://www.youtube.com/watch?feature=player_embedded&v=dOjpAsqdAKw
     
  25. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    The runtime animation portion of Smooth Moves is actually handled entirely by Unity. Smooth Moves produces a skinned mesh with an animation component that Unity controls. Since I did not write the animation from scratch, I cannot change the way Unity starts and stops the looping.

    These links discussing Unity's animation system may help you find a solution that works for your project:

    http://unity3d.com/support/documentation/Manual/Character-Animation.html
    http://unity3d.com/support/documentation/Manual/Animation%20Scripting
     
  26. bandingyue

    bandingyue

    Joined:
    Nov 25, 2011
    Posts:
    131
    this is an amazing plugin.

    but i still want to know what`s the diffences between this and EasyMotion2D.
     
  27. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Thanks, BanDingyue.

    I don't own EasyMotion2D, so I wouldn't be able to give a fair comparison, other than the price of Smooth Moves currently being lower due to the sale. Perhaps some other people that have tried both packages can give a good rundown on the differences.
     
  28. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    (found solution myself: I'm dumb :p)
     
  29. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Yeah, sorry. I decided to organize everything under a single "Smooth Moves" menu for easier lookup. The tutorials were created before this. I am working on documentation right now and hopefully will have some time to redo the tutorials to better reflect all the new features that have been added.
     
  30. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    I have to say that the new organization is way better than the previous one... I don't know how I didn't see it :D
     
  31. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Yeah, Unity discourages devs from putting all their menu items under a single top level menu, but I didn't like everything spread out so I did it anyway. I agree, it looks much cleaner. Guess they don't want the menu cluttered with a bunch of plugins taking up space at the top level.
     
  32. robin_notts

    robin_notts

    Joined:
    Apr 7, 2010
    Posts:
    86
    Something I'd love to see in Smoothmoves: the ability to turn a bone into a Ragespline object and animate it as you would an image/transform. It would be a great combination. Is this something you've considered?

    I like the top level menu as well.
     
  33. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    I haven't worked with Ragespline objects, so I'm not sure what all that would entail. Perhaps someday I will get that plugin when I get some free time. :)
     
  34. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Unity has approved 1.9.1, so head over to the asset store to download the update!

    Major features:
    - Ability to select and drag keyframes back and forth in time
    - Ability to insert and remove frames, shifting future frames back and forth in time
    - Ability to select which properties to copy and paste through the settings window

    Major bugs:
    - Fixed the freeze that sometimes occurs when clicking on the Pivot Editor button in the keyframe properties window

    Check out the readme file that comes with the package for a full list of features and bug fixes.
     
  35. TorontoJoe

    TorontoJoe

    Joined:
    Mar 25, 2012
    Posts:
    32
    I have both; Smooth Moves is the superior product. Easier to use, more polished, cleaner interface, better tutorials etc. And echo17 is a great guy. What I like about EasyMotion2D is the dockable animation editor window, and a better Atlas Editor.
     
    Last edited: May 31, 2012
  36. bandingyue

    bandingyue

    Joined:
    Nov 25, 2011
    Posts:
    131
    My Question is:

    If I have a animation of a cat. And a animation of a dog.

    can I make only one atlas texture with both cat and dog?
     
  37. hidekihanida

    hidekihanida

    Joined:
    May 30, 2012
    Posts:
    5
    Actually I am checking the animation name and the bone name, but if you want to use several triggers within the same animation+bone you can, like you said, reference the "frame". But by saying "reference the frame" you mean to reference an integer value like "if (frame == 10)" no? If you shift the frames where the user trigger is raised that 10 will no longer be valid and I have to readjust it again in the source code. Is there any way to assign an alias name to the frame?

    I know that you are using unity's built-in animation components, and in the animation event class you can specify a string/float/int value when calling your callback. I would like to have such kind of method in order to identify easily in which circumstance the trigger is being raised.

    Thanks in advance.
     
  38. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Hey Echo,

    in my game, I have identical animations for different characters. So I created the bone animations for the first one, then duplicated it and started changing the textures. Problem is: when I do that, the new textures are placed at a different scale (for example: new head was higher, and it appears squashed instead), even if the scale (image/localScale) appears to be set to 1.
     
  39. robin_notts

    robin_notts

    Joined:
    Apr 7, 2010
    Posts:
    86
    I would add a vote for User Trigger labels as well, if it is possible.
     
  40. sleekdigital

    sleekdigital

    Joined:
    May 31, 2012
    Posts:
    133
    In the Asset Store, I re-downloaded and my readme file still says 1.9.0
     
  41. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Yes, you could do that, as long as the source textures all fit within a single atlas. You'd still have at least one draw call per animated mesh since Unity won't batch skinned meshes for some reason, so it might not gain you anything to combine the atlases.
     
  42. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    I see your point, that is a good idea. I had not thought about moving the frames later and having to change your logic.

    FYI, I'm not using the animation events in Smooth Moves. I had originally started with that, but it caused problems on mobile platforms, so I created a homespun event system. I'll look into integrating variables into the user trigger event.
     
  43. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252

    Try re-generating the atlas for your new animation. For some odd reason, Unity thinks that a power of two is the best way to default a source texture. My atlas builder tries to correct that by making it a non-power of two, but sometimes it doesn't take, which leaves some of the source textures looking squashed.
     
  44. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Yeah, sorry. 1.9.0 = 1.9.1. Unity made me resubmit my package because I had to change it to the sale price, not my original price. They require a new version for resubmission, so I bumped it up to 1.9.1 without actually changing anything. Sorry for the confusion.
     
  45. knightking

    knightking

    Joined:
    May 31, 2012
    Posts:
    2
    Hey echo17, I don't see the buy button in the asset store. How do we make a purchase?
     
  46. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Hmmm... not sure why it isn't showing for you. I can see the buy button in the asset store. Perhaps it is a temporary glitch in their system. Try going to This Link. It will open the asset store in your unity program when you click the "Open Asset Store" button.
     
  47. knightking

    knightking

    Joined:
    May 31, 2012
    Posts:
    2
    Tried your link but leads me to where I was at first - Asset Store in Unity with no buy link for Smooth Move"
    I can see buy links for other assets... Not certain why I don't see it for Smooth Moves.:confused:
     
  48. basyong

    basyong

    Joined:
    May 31, 2012
    Posts:
    1
    Hi echo17,

    I have a follow up question in regards to handling inventory system like in an rpg. Do i need to search for an existing Item being used everytime i want to swap it with a new item? Also, is there way to programmatically define the textureSearchReplace instead of doing it in the inspector? Want to be able to do the swap during runtime with selecting an item from the inventory or pressing a button.
     
  49. bandingyue

    bandingyue

    Joined:
    Nov 25, 2011
    Posts:
    131
    Thank you for your reply !

    I have had a test.

    Yes! as you said.i did not get anything.

    I have 6 skin meshes with animation.

    they have the same material.

    and it still have 6 draw Calls.

    But i still want to know is it more quicker in load when using a combine atlas textures?
     
  50. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Yes, you will need to do a search replace each time you switch your textures. You set up all your replacements in the inspector, then at runtime you can switch call which ever ones are needed at that time. So at design time you will specify which textures are replaced and with what new texture. At runtime you will call the appropriate replacement that you set up at design time. You can do this over and over at runtime.

    Again, I realize this isn't the most elegant solution and I plan on having an integrated swap management system in the animation editor some day. No clue how long this will be, however.