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

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,249
  2. sanjodev

    sanjodev

    Joined:
    May 29, 2012
    Posts:
    63
    Ah yeah, I remember reading about that a while back and now I'll remember it as a workaround to get around Unity's issue. I used to have BoneAnimation as its own prefab in my last project, but I been reworking many things, so I'll probably just deal with it and stick to my workaround so that I can have BoneAnimation object be a child of a prefab.
     
  3. dasbin

    dasbin

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

    I'm getting a similar range error after only updating to the latest version. Nothing else changed; it must be *something* to do with this version.
    Strangely, everything seems to play fine, but the error shows up in the console every time.

    I think it may have something to do with the Playmaker actions for Smooth Moves. Is there a chance they use any outdated methods?

    This is the exact error:

     
    Last edited: Apr 30, 2013
  4. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,249
    Hmmm...not sure. I can't seem to replicate this problem. Can you send me a simplified project that demonstrates this to support@echo17.com?
     
  5. dasbin

    dasbin

    Joined:
    Jan 14, 2012
    Posts:
    261
    Oops, my mistake. Fixed. There was one stealthy little animation hiding away that I had forgotten to rebuild... sorry to waste your time.
     
  6. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,249
    Ah, good deal. Thanks for the feedback!
     
  7. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,249
    SmoothMoves 2.2.2 Approved and in the Asset Store!

    Download here: http://u3d.as/content/echo17/smooth-moves/2Fn
    Be sure to back up your work and download the update into a new project. You can copy the code over into your current projects using your OS's file system to ensure no import errors occur. See this FAQ for more information on upgrading:

    http://www.echo17.com/forum/index.php?topic=247.msg361#msg361

    Check out this link for a complete list of changes:

    http://www.echo17.com/forum/index.php?topic=2.msg500#msg500

    FYI, you can follow these updates on my Facebook, Google+, and Twitter feeds as well (links in my signature)
     
    Last edited: May 4, 2013
  8. danboutros

    danboutros

    Joined:
    Mar 26, 2012
    Posts:
    32
    Hey Layne;

    Collider question:
    We're currently using a mix of boxes and spheres as colliders for our characters.

    Problem is, while we can explicitly define the Z axis on the box colliders, we're stuck with radius for spheres, which is creating issues for us in our environment (fake 2D), where enemies in the background are getting hit by colliders they're not supposed to be connecting with.

    At present, it looks like we may have to redo all colliders across the game to get tighter control of this, but that means going to squares and potentially increasing the amount of colliders to best cover the shapes of our character bodies.

    Is a more detailed collider control / design a planned future feature? If not soon, do you have any suggestions to help with the problem in the present?
     
    Last edited: May 1, 2013
  9. Subliminalman

    Subliminalman

    Joined:
    Sep 11, 2012
    Posts:
    47
    Animation Data question.

    So I'm trying to get an atlas at run time using the code below and I keep getting null on my animationData object. This used to work on SmoothMoves 1.x but does not work anymore when I upgraded to 2.x . Is there an easier/alternative way to get the atlas or should I just revert back to 1.x?
    Code (csharp):
    1.  
    2.     public TextureAtlas GetAtlas(BoneAnimation _boneAnim, string _boneName)
    3.     {  
    4.         //Find which animation clip to use
    5.         int clipIndex = _boneAnimation.animationData.GetClipIndexFromName(_boneAnimation.clip.name, false);
    6.        
    7.         //Get the first keyframe from the animation clip for the bone we specified
    8.         KeyframeSM keyframe = _boneAnimation.animationData.animationClips[clipIndex].GetKeyframe(0, _boneAnimation.animationData.GetBoneDataIndexFromName(_boneName, false));
    9.  
    10.         //Return the atlas on the keyframe
    11.         return keyframe.atlas;
    12.     }
     
  10. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,249
    It's a good question. I'm using Unity's collider primitives for now (sphere and box). The only other collider types that Unity provides are capsule and mesh. Capsule, you would see the same issues as sphere. Mesh would be boxes since that is what the mesh consists of.

    If you want really fine control over your mesh, I'd suggest looking at the new plugin designed around SmoothMoves and other 2D plugins called 2D ColliderGen. It creates a collider around your animation, fitting the texture contours. Check it out here:

    https://www.assetstore.unity3d.com/#/content/7540
     
  11. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,249
    Item #10 under features of the 2.2.0 change log (http://www.echo17.com/forum/index.php?topic=2.msg436#msg436) shows that the animation data is no longer attached at runtime. The primary reason for this is because Unity will load any resource that you have referenced in your scene. The animation data was largely composed of structures and data that is only relevant to the editor, so bringing it in at runtime was adding a lot of memory overhead. I kept the reference to the animation data member so that I could upgrade to point to the GUID of the animation data asset.

    If you are creating an editor script, you can use the new member "animationDataGUID" to look up the atlas with something like:

    Code (csharp):
    1.  
    2.  
    3. TextureAtlas atlas = (TextureAtlas)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(animationDataGUID), typeof(TextureAtlas));
    4.  
    5.  
    This will only work in the editor however since it uses UnityEditor.dll and the asset database.

    FYI, I purposefully left "animationData" undocumented because it was not a supported feature of the BoneAnimation script. It's safest to assume that anything undocumented is subject to change.
     
    Last edited: May 1, 2013
  12. Subliminalman

    Subliminalman

    Joined:
    Sep 11, 2012
    Posts:
    47
    Ah ok. So is there no way to get the atlas at runtime for ingame? I use it for my character customization.
     
  13. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,249
    No, unfortunately, the runtime implementation has only the concept of materials and uv positions, translated from the atlas. I tried to streamline the memory demands by cutting free as much as I could.

    Perhaps there may be another way to get what you need through the existing structures. You can send me an email to support@echo17.com and let me know what your end goal is. There might be information already in the BoneAnimation that can accommodate your needs.
     
  14. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,249
    SmoothMoves 2.2.3 Approved and in the Asset Store

    Download here: http://u3d.as/content/echo17/smooth-moves/2Fn

    Be sure to back up your work and download the update into a new project. You can copy the code over into your current projects using your OS's file system to ensure no import errors occur. See this FAQ for more information on upgrading:

    http://www.echo17.com/forum/index.php?topic=247.msg361#msg361

    Check out this link for a complete list of changes:

    http://www.echo17.com/forum/index.php?topic=2.msg512#msg512

    FYI, you can follow these updates on my Facebook, Google+, and Twitter feeds as well (links in my signature)
     
  15. casimps1

    casimps1

    Joined:
    Jul 28, 2012
    Posts:
    254
    Can somebody sell me on Smooth Moves vs UMotion 2D or Spine (by Esoteric Software)?

    I'm trying to understand the differences beyond the obvious - that Smooth Moves is integrated into Unity and the others are external tools that export assets for use in Unity. They all seem to be fairly solid pacakages for creating bone-based 2D animations. Is there something Smooth Moves can do that the others can't?
     
  16. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,249
    Thank you everyone for a wonderful April!

    SmoothMoves has held the #5 Top Paid and #7 Top Grossing spots for several weeks now thanks to all of you. Happy animating!

     
  17. moopi

    moopi

    Joined:
    Apr 24, 2012
    Posts:
    39
    Hi Echo,

    I need to get Smooth Moves animations working when the Time.timeScale is set to zero. I'm already having a specific Timer script with own Timer.deltaTime variable which is based on Time.realtimeSinceStartup. Is there any easy way to get bone animations working when Time.timeScale is set to zero?

    Br,
    -Moopi
     
  18. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,249
    I'm not sure what you mean by "working", so I'll assume that you aren't seeing any triggers occurring when you set your animation to a specific time or frame. In the latest version of SmoothMoves I switched the animation over to using Unity's animation events. Unity does not fire these events if the animation fps is set to zero. To get around this, I created a new function called "ForceAnimationEvent" in the BoneAnimation class. This will fire all triggers at the requested frame, whether or not the animation is actually at that point, or running at all.

    You can see an example of this in the Score.cs script in the "Rise of the Dough" minigame included with SmoothMoves. You can find this being called in the "Value" property. The score animation does not run like a typical animation so I set the frame manually to get the desired number displayed. Since the animation is not running, animation events are not fired, so calling ForceAnimationEvent after setting the frame makes it work again.
     
  19. casimps1

    casimps1

    Joined:
    Jul 28, 2012
    Posts:
    254
    echo17, no response to this? I've eliminated UMotion 2D as a contender, so now it's between Smooth Moves and Spine and I'd really like to make an educated decision here. I've asked the same question at the Spine forum and their devs responded explaining the pros of Spine over Smooth Moves. Can you give me some pros of Smooth Moves over Spine?

    Thanks!
     
  20. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,249
    I saw your post, but I didn't think it would be fair for me to respond since I am probably biased toward my product. Also, I don't have any experience using Spine or UMotion, so I can only tell you what SmoothMoves is capable of. If you have specific questions about what you would like to accomplish, feel free to ask them here, on my dedicated forum at:

    http://www.echo17.com/forum/index.php?board=2.0

    or you can contact me by email at: support@echo17.com.
     
  21. casimps1

    casimps1

    Joined:
    Jul 28, 2012
    Posts:
    254
    Ha, no worries, I came here looking for a biased response. :)

    Well, how about this, I'll mention what some of the Spine devs have listed as selling points for their product over Smooth Moves and let you respond. I hope this is OK doing this comparison here. I'm not trying to hurt your business in any way, just want an honest comparison that might be useful for others as well.

    So, pros of using Spine over Smooth Moves according to the Spine devs:

    - The Spine runtime for Unity comes as open source C# code whereas Smooth Moves distributes DLLs
    - Spine is engine agnostic and can work beyond just Unity (though honestly I don't care since I use Unity exclusively)
    - Spine doesn't use Skinned Mesh Renderers, therefore 100 copies of the same character take only 1 draw call (whereas Smooth Moves would take 100 draw calls to do the same thing)
    - Spine has a bind pose that all anims are relative to, so you can lean the bind pose and then all anims automatically lean as well
    - Spine supports IK (via their Pose tool) whereas Smooth Moves does not
    - Spine includes the concept of "skins" to make it easy to make multiple characters that look different but share the same skeleton and anims
    - Smooth Moves may not gracefully handle procedural animation (programmatically modifying a bone's transform), they weren't sure though

    I don't know how accurate these claims are since they are not all that familiar with Smooth Moves either, so feel free to correct anything that's not true.

    Thanks for your time!
     
  22. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,249
    These are all true, though I am looking at ways to:

    - Open up the runtime code
    - Options to avoid the skinned mesh draw call limitation
    - IK
    - Base pose (though with mixing animations you could probably achieve a similar result)

    No idea when these will get implemented, however.

    SmoothMoves has a similar concept where you can swap out materials or just textures on bones. I'm also looking into ways to create groups of textures for swapping (sort of a skin concept).

    You can get the transforms of a bone and modify it at runtime. At that point the transform is like any other Unity transform so if you are familiar with moving transforms programmatically it should be a piece of cake. Have a look at this FAQ for more information:

    http://www.echo17.com/forum/index.php?topic=247.msg347#msg347

    Again, I haven't tried Spine, so I don't know what features SmoothMoves has over it.

    Looking through the docs and stuff, it doesn't appear they have the ability to attach colliders to bones that can be toggled at any point in an animation. To me, colliders are a critical part of a Unity project. I couldn't imagine creating an animation without them. You can see in the "Rise of the Dough" minigame that the Chef animation has a collider on the weapon that turns on when attacking (at the frames you specify). This allows you to specify when colliders are active and can interact with a scene. You can check out the minigame here:

    Free project: u3d.as/content/echo17/rise-of-the-dough/3A4
    Live Demo: http://echo17.com/smoothmoves_riseofthedough.html

    Also, SmoothMoves can utilize user triggers that fire off delegates that allow you to perform any action for any frame (such as playing a sound file at a particular point in an animation).

    Other Unity plugins have integration with SmoothMoves, you can see a few of the ones I am aware of here:

    Playmaker: http://www.hutonggames.com/
    2D Jump'n'Run Framework: http://forum.unity3d.com/threads/90374-Released-2D-Jump-n-Run-Framework
    2D ColliderGen: http://pixelcloudgames.com/tools/2d-collidergen

    You might want to have a look through the FAQ's on my page, they can probably give you a good idea of some of the more common questions people have:

    http://www.echo17.com/forum/index.php?topic=247.0

    Lastly, I can't comment on other companies' responsiveness, but I usually respond to emails within a few hours, a little bit longer on weekends. That isn't a selling point to everyone, but I've always enjoyed products more when I see that the developer is active and is willing to take some time to help me out. If you have any questions, I have a bazillion ways to contact me. Check out the links in my signature for the methods which will get you a hotline to my support.
     
    Last edited: May 7, 2013
  23. moopi

    moopi

    Joined:
    Apr 24, 2012
    Posts:
    39
    Thanks Echo, I have to check your demo implementation.

    I'm currently facing some other issues with the smooth moves:

    If I change the local scale of bone animation object in the Unity's Inspector and execute force build for the bone animation, the local scale is set back to 1,1,1 instead of the one set by me. This is an issue for me, as I have scenes with different cameras and different scales (i.e. menu scenes are scaled so that one unity unit is one pixel and actual game scenes are scaled so that one unity unit is 16 pixels), so the mesh import scale in the bone animation does not make the trick. As a workaround, I created a script which sets objects localScale at the awake, but it seems that the force build will get rid of the scripts attached to the bone animation object (how one can attach a script to the bone animation object if the force build removes it?).

    Texture atlas update issue: If I change one texture image in the photoshop (no changes to the size or transparency of the texture) and rebuild the texture atlas were this texture is in use, the result is that all textures in my bone animation object are messed up (like the scale of those textures was somehow increased and shape clipped). If I open the bone animation data in the SmoothMoves animation editor, textures seems to be ok.
     
  24. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,249
    Unity's animation curves take precedence and will overwrite anything that you set in the inspector or the Awake function. To control a bone's transform manually, you can make your changes in the LateUpdate function. Have a look at this FAQ:

    http://www.echo17.com/forum/index.php?topic=247.msg347#msg347

    When you rebuild a texture atlas, the packing function will look for the most optimized solution to fit all your textures. If the solution changes, then your UV coordinates will be altered, making the UV coordinates in your animations invalid. You just need to update you animations by rebuilding them after making a change to the atlas. Have a look at this FAQ:

    http://www.echo17.com/forum/index.php?topic=247.msg368#msg368

    If you are on a version prior to 2.2.0 then your source images are clipped before resizing the atlas if they don't fit the max atlas size specified. 2.2.0+ will fit all your textures into an atlas of 4096 x 4096, then resize down to the max size you request to avoid clipping. If your source images are larger than the 4096 x 4096 you will still see clipping, however, so in this case you'll need to break your atlas into multiple atlases. See #4 under "Bug Fixes":

    http://www.echo17.com/forum/index.php?topic=2.msg436#msg436

    The animation editor uses your source textures, while the bone animation uses the final atlas texture.
     
  25. moopi

    moopi

    Joined:
    Apr 24, 2012
    Posts:
    39
    Thanks, Echo.

    I updated Smooth Moves to the latest version and now I managed to get texture atlas working.

    However, I'm still having an issue with the script attached to the bone animation object: when I push "Force build this Bone Animation..." button, the script attached to the object is removed. How I can attach a script to the bone animation object? Or should I make a parent (empty game object) with the script and access this object child through the script? Then how about making such an object as a prefab? Without a script I'm not able to control transform manually... (script is removed when "Force build... is pressed or if the textureatlas is rebuild and "Auto-build is ON" is set in Control Panel)

    Also, after the update, my animation does not anymore update colors (I have "update colors" checked in bone animation). Instead, I'm now having following errors when running my game:

    Could not find an animation state for the animation [Idle]
    UnityEngine.Debug:LogError(Object)
    SmoothMoves.BoneAnimation:Awake()

    NullReferenceException: Object reference not set to an instance of an object
    SmoothMoves.BoneAnimation.GetHighestLayerPlayingAnimationClip (System.Int32 highestClipIndex, System.Single highestTime)
    SmoothMoves.BoneAnimation.UpdateColors ()
    SmoothMoves.BoneAnimation.LateFrameUpdate ()
    SmoothMoves.AnimationManager.LateUpdate ()

    Br,
    - Moopi
     
  26. moopi

    moopi

    Joined:
    Apr 24, 2012
    Posts:
    39
    And I'm using Unity 3.5.7f6
     
  27. danboutros

    danboutros

    Joined:
    Mar 26, 2012
    Posts:
    32
    Hi Layne;

    I've been noticing some issues in blending our animations. Specifically that some animations won't blend fast enough, or some blends (bone specific) do strange things like having a the feature of one animation blend in an undesirable way.

    For example, rocket boosters on a jetpack folding away, rather than just turning off.

    Is there a way to control this in detail, or do I only have the "weight" settings to play with?

    Dan
     
  28. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,249
    This is generally how I do it. I try to isolate the BoneAnimations whenever possible. You can easily reference them from other scripts by creating a public BoneAnimation variable and connect them in the inspector.

    Just from your description, it looks like you don't have the animation clip named "Idle" in your animation data. First thing I would check would be that the casing and name is correct.
     
  29. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,249
    I would have to see your animations to understand what is happening and give you a good diagnosis. If you send me a simplified version of your project to support@echo17.com, I have a look.
     
  30. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,249
    OK, so I had more of a chance to look at Spine and now I have a better understanding of the differences between it and SmoothMoves. I'll list the biggest advantages that SmoothMoves has here:

    1) Multiple atlases materials at one time, dynamic depth

    SmoothMoves allows multiple atlases at any given time. The animation system uses submeshes inside the Unity mesh to allow you to have more than one material assigned to groups of quads. This also allows you to have quads of some materials nested between quads of other materials. For example, your animation might have an atlas of a chef and an atlas of weapons. By using submeshes, you can have the bones with weapon textures display behind a chef's hand and in front of a chef's head. Not only this, but you can do this dynamically throughout an animation clip. SmoothMoves will always optimize the number of submeshes needed for any given moment.



    It doesn't appear that Spine allows more than a single atlas on your animation at one time, so you will be stuck lumping all of your textures into a single material. Not only are you constrained by this limitation, but you won't be able to dynamically shift the depth of other atlas bones at runtime, let alone sandwich them between other bones.

    2) Mesh optimization

    SmoothMoves only rebuilds the mesh whenever something about the mesh has changed (bone depth changed, texture changed on a bone, pivot updated, etc.). Rebuilding the mesh is a costly procedure as you have to allocate arrays for each of the components (color, vertices, triangles, etc.). SmoothMoves uses a skinned mesh renderer that lets you build your mesh once and then move the vertices around using Unity's built-in low-level (read fast) code. The skinned mesh renderer does require a separate draw call, but this is not the scary bottleneck that it once was back in 2007 when the first smart phones were starting to appear. I would much rather eat a separate draw call than bog down my mesh with being recalculated every frame.

    Spine rebuilds the mesh EVERY SINGLE FRAME. :eek: My jaw almost dropped to the floor when I saw this! For super simple animations you probably won't notice this impact, but once you start to get anywhere near production level detail with your animations, this is going to seriously impact the performance, especially on mobile devices.

    3) Events

    SmoothMoves has the concept of events within an animation clip. I can't stress how critical this is for interacting with your scene.

    With SmoothMoves, you can change the depth of your bones at any point. For example, you might have a character's arm move in front of the character for a few frames, then move back behind the character. You can see this in the Chef animation where he attacks.



    Another event is the user trigger. This allows you to specify something that should happen for a frame in a clip. You can then process this in your code however you choose. This is great for playing sounds, starting other animations....just basically interacting with the scene.



    Colliders are probably SmoothMoves strongest event. You can turn colliders on and off by frame for any clip, even change what type of collider they are from frame to frame. This lets you have full control over how your animation will interact with its environment. Sure, you could attach a static collider to a bone, post-build, but then you would have a fully active collider that is always on. With SmoothMoves, you can turn off colliders when they aren't needed. For example, you probably only want your weapon colliders on while they are attacking, otherwise you would get a lot of false hits while just standing or walking around. SmoothMoves colliders also leverage Unity's powerful physics matrix by letting you set the layer that they will collide with. This can also filter out unwanted collisions (say, with allies for instance).



    Spine doesn't seem to have any event management or processing. This means that you won't be able to set up triggers for your scripts, change depths dynamically (even for a single atlas), or toggle colliders, let alone set the layer of the collider. I can't see how to use an animation that would interact with a scene with this system. You'll have to do a lot of external programming just to get the same level of functionality that SmoothMoves provides out of the box.

    4) Familiar Workflow

    SmoothMoves uses a simplified workflow that is similar to what animators are already used to with Unity. If you have done any modeling in Maya, 3D Studio, Blender, etc, you will first export your animation to fbx, then import into Unity. Then you use that imported animation in your scene, which comes in as a skinned mesh. SmoothMoves skips the export / import and gets you directly to the skinned mesh. If you are an experienced user of Unity, you will find the workflow after the skinned mesh step exactly the same as what you are used to. If you have worked with animating skinned meshes and manipulating transforms at runtime, then the transition will be seamless. Also, SmoothMoves builds a hierarchy of game objects / transforms just like an imported 3D mesh would into your scene. You will then have direct access to each bone (attaching objects, moving transforms) like you normally would.



    The skinned mesh renderer lets you play animation clips just like you would from an imported 3D character from a 3rd party modeler. You can mix, blend, fade, and queue animations using Unity's animation system just like you would with a normal 3D model. Have a look at these links for more information on Unity's animation system:

    Unity Animation
    Animation Scripting
    Animation class

    Spine does not use skinned meshes or a gameobject / transform scene hierarchy.

    5) Example Game

    SmoothMoves comes with a complete minigame that shows off pretty much every feature that can be used. The characters are complete, have several animations, and can interact with each other. Even the GUI was created with SmoothMoves (not recommended, but great for illustration).



    Bottom line:

    SmoothMoves is made for Unity. Spine is designed to be compatible with an array of engines. SmoothMoves' greatest strength is that it leverages Unity for performance, familiar workflow, and full interaction with a scene. As features are added, they will be for Unity, without having the limitation of having to be compatible with other products. With Unity being a cross-platform engine, compatibility with other products becomes a moot point.

    There may be other features that SmoothMoves has over Spine, but honestly after hitting these five (at least the first four) listed above, I wouldn't see the point of going further to determine what they are. In my own game design, I need each and every one of these (and all of SmoothMoves features) to have a fully functional, fully interactive character in my scene.
     
    Last edited: May 9, 2013
  31. moopi

    moopi

    Joined:
    Apr 24, 2012
    Posts:
    39
    Hi Echo,

    It seems that some part of SmoothMoves is case sensitive and other part is not or some script is not updating components/resources correctly. I have a clip (In the Animation Editor) called "IDLE". The same name is visible in the XXXBoneAnimation_Resources folder. If I change the name of the animation to "Idle" in the Animation Editor, the clip in the resources folder remains to be named "IDLE" -> When running the game, I got the error "Could not find an animation state for the animation [Idle]" -> I renamed clip back to IDLE and managed to get build working.


    Br,

    Moopi
     
  32. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,249
    Thanks for the bug report! I'll take a look and see what I can find.

    [EDIT]

    I think I see what is happening. When Unity searches for the existence of an asset, it is not case sensitive, so it sees the animation clip in the resources folder, even though it has different casing, and thinks it is there.

    SmoothMoves, on the other hand, uses string comparison with case sensitivity, so when you call an animation, the casing has to match.

    I'll look for a solution to merge the two different ways of searching between Unity's asset database and SmoothMoves clip library.

    [/EDIT]
     
    Last edited: May 13, 2013
  33. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,249
    SmoothMoves 2.2.4 Approved and in the Asset Store

    Download here: http://u3d.as/content/echo17/smooth-moves/2Fn

    Be sure to back up your work and download the update into a new project. You can copy the code over into your current projects using your OS's file system to ensure no import errors occur. See this FAQ for more information on upgrading:

    http://www.echo17.com/forum/index.php?topic=247.msg361#msg361

    Check out this link for a complete list of changes:

    http://www.echo17.com/forum/index.php?topic=2.msg543#msg543

    FYI, you can follow these updates on my Facebook, Google+, and Twitter feeds as well (links in my signature)
     
  34. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,249
    I've moved SmoothMoves to the "Editor Extensions > 2D Sprite Management" category in the Asset Store. I feel this category is a better fit than the animation category it was in.

    Just FYI, in case you are browsing for it!
     
  35. Amitloaf

    Amitloaf

    Joined:
    Jan 30, 2012
    Posts:
    97
    Hello! I've been having a minor problem.
    I'm using Update Colors (for alpha blending).
    After playing the attack animation, my character disappears. If I queue the Idle animation before my animation finishes, it switches nicely. But I need to wait for the animation to finish (by checking isPlaying) so I can't queue anything until the animation is over.
    Why is my character disappearing and is there a way to prevent it?
    Also, note that I check and all bones' keyframes color is 1,1,1,1 and full blending (except for the alpha blended one somewhere).
     
  36. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,249
    The latest service release (2.2.4) addresses this issue. Try upgrading SmoothMoves to see if that resolves your issue. Have a look at the changelog here for more information:

    http://www.echo17.com/forum/index.php?topic=2.msg543#msg543
     
  37. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,249
  38. echoic

    echoic

    Joined:
    Apr 29, 2011
    Posts:
    89
    Is there any way to duplicate a sprite without having it permanently "partnered" with the original sprite? I have a lot of shop items that the same image but a different color.. if I duplicate a sprite and change the color, it changes the color of every sprite that stemmed from that original. Any ideas? Thank you!
     
  39. ColossalDuck

    ColossalDuck

    Joined:
    Jun 6, 2009
    Posts:
    3,246
    Try this at the start: sprite.DisconnectInstance();
     
  40. echoic

    echoic

    Joined:
    Apr 29, 2011
    Posts:
    89
    Rad.. it works. Thanks man!
     
  41. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,249
    Thanks, KHopcraft, that was what I would recommend as well.

    @echoic: when Unity duplicates something with a mesh attached, it makes the two objects share the mesh data. So any changes you make to one will show up in others. By calling the disconnectinstance function, you will tell SmoothMoves to build a mesh from scratch with the same properties as the shared mesh, thus making the meshes separate. You can also do this at design time by clicking on the "Create Separate Mesh" button in the sprite inspector.
     
  42. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,249
    I've create a simple Editor script that will allow you to copy animation clip keyframes from one animation to another, even if the bone structure is different between the animations.

    See this FAQ for instructions and a link to the script: CopyAnimationClipWindow.cs FAQ
     
  43. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,249
    New SmoothMoves Playmaker action scripts!

    Check out the links on my website here: http://www.echo17.com/smoothmoves.html in the "Extra Goodies" section.

    There are two links:
    • Just the Playmaker action scripts which you can put into the Playmaker actions folder
    • Unity project containing the action scripts and example scenes. For this one, be sure you have a project with Playmaker and SmoothMoves already installed!



    See this FAQ for more information.​
     
    Last edited: May 20, 2013
  44. moopi

    moopi

    Joined:
    Apr 24, 2012
    Posts:
    39
    Hi

    I finally had time to come back to wonder how to play BoneAnimation when TimeScale = 0.
    What is the easiest way to script BoneAnimation working with javascript when TimeScale = 0? I want the BoneAnimation be played just like it plays when the TimeScale = 1.

    Somehow I'm not able to access BoneAnimation through "gameObject.GetComponent(BoneAnimation)" (Got error BCE0005: Unknown identifier: 'BoneAnimation').

    - Moopi
     
  45. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,249
    By TimeScale = 0, do you mean setting your FPS (frames per second) to zero? If so, your animation will not progress if the fps is zero, it will just remain on whatever frame you set it to.

    This can be useful for animations that are really just state animations, like a score animation where each frame is a different number. You can see this is what I do in the "Rise of the Dough" minigame for the score animation. Since Unity doesn't fire animation events when your fps is zero, you'll also need to call ForceAnimationEvent after setting the animation frame. Take a look at the score.cs script in the "Value" property. You'll see that after setting the normalized time, I call "ForceAnimationEvent" to fire the triggers on that frame.

    I don't know what this error would signify. I've never encountered that before. It sounds like you are not referencing the SmoothMoves library in your script. You'll either need to import the library or type your classes like : SmoothMoves.BoneAnimation.
     
  46. moopi

    moopi

    Joined:
    Apr 24, 2012
    Posts:
    39
    Yes, I'm using TimeScale = 0 to stop physics engine during pause etc. The side effect of this is that all Unity animations will stop playing. I'm already
    using a script to play Unity animations during the TimeScale = 0:

    var clipName : String = "Idle";

    private var anim : Animation;
    private var animState : AnimationState;
    private var startTime : float;
    private var currentTime : float = 0;


    function Awake()
    {
    anim = gameObject.GetComponent(Animation);
    animState = anim[clipName];
    animState.speed = 0;
    animState.time = 0;
    animState.enabled = false;
    anim.Stop();
    }

    function Start ()
    {
    animState.wrapMode = WrapMode.Loop;
    }

    function Update ()
    {
    currentTime = Time.realtimeSinceStartup - startTime + animState.length;
    animState.time = currentTime;
    animState.enabled = true;
    anim.Sample();
    animState.enabled = false;
    }


    However, this script does not work with BoneAnimation. I was wondering if there is a easy way to do same with SmoothMoves/BoneAnimation.

    The error was due missing "import SmoothMoves" in my script. It seems that I'm now able to get access to the BoneAnimation by making a script (which is attached to the parent):


    import SmoothMoves;

    var bAnimation : BoneAnimation;

    function Start ()
    {
    bAnimation.Play();
    }
     
  47. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,249
    I'm not sure why BoneAnimation would not work since it just wraps an animation component, normalizing the time values to the FPS set in the editor. You could probably use the same code you supplied, just change AnimationState to AnimationStateSM. Also, after you set the time in the Update function, be sure to call ForceAnimationEvent for the current frame of the animation since no events will fire if an animation is set to zero FPS.

    Have a look at the API for more information:

    http://www.echo17.com/support/smoothmoves_api_documentation/namespace_smooth_moves.html
     
  48. moopi

    moopi

    Joined:
    Apr 24, 2012
    Posts:
    39
    Hi,

    Animation seems to be working at some level (I changed AnimationState -> AnimationStateSM, Animation -> BoneAnimation), even I'm not using ForceAnimationEvent. I did't find any impact to the animation when calling this function (I don't have events attached in my animations at the moment). I'm assuming this will fire animation events if they are timed to happen at current point of time (given as a time parameter in ForceAnimationEvent function call) as Unity animation events:"Animation Events, which allow you to call functions in the object's script at specified points in the timeline".

    It seems that AnimationStateSM.totalFrames does not exist (Assets/Scripts/MiscScripts/AnimationPlayBoneAnimation.js(24,28): BCE0019: 'totalFrames' is not a member of 'SmoothMoves.AnimationStateSM'. ).

    - Moopi
     
  49. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,249
    SmoothMoves uses animation events to perform certain triggers like switching textures, changing materials, changing depth, change bone visibility, changing pivots, firing user triggers, toggling colliders, etc. If you are doing any of these things in your animation, then they will get an animation event. Calling ForceAnimationEvent ensures that the appropriate event is fired for the frame (or time) you set when the animation speed is set to zero.

    This member was added in version 2.2.4 (the latest version). Here's a link to the change log for more information:

    http://www.echo17.com/forum/index.php?topic=2.msg543#msg543
     
  50. moopi

    moopi

    Joined:
    Apr 24, 2012
    Posts:
    39
    Ok. I made a test clip where the bone depth changes. It seems that depth is not animated, even I made an inclusion of anim.ForceAnimationEvent(clipName,animStateSM.frameInt); in the update loop. I checked that animStateSM.frameInt counts from 1,2,3....n+1.
    My current Update function (plays animation but events are not working):

    function Update ()
    {
    currentTime = Time.realtimeSinceStartup - startTime + animStateSM.length;
    animStateSM.time = currentTime;
    anim.ForceAnimationEvent(clipName,animStateSM.frameInt);
    }


    Is there something else I have to make to get events working?

    - Moopi