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
    Yes, that is quite annoying, I agree. dasbin and kenwong are correct, however. This is a Unity "feature" or "bug" depending on your viewpoint. The algorithm I use to pack the textures is Unity's own, built-in function: Texture2D.PackTextures

    I would go with dasbin's suggestion #2: build at a higher resolution, then resize the resultant atlas texture by setting its maximum size lower in the inspector.
     
  2. danboutros

    danboutros

    Joined:
    Mar 26, 2012
    Posts:
    32
    Ah! Thank you KenWong, Dasbin and Echo17.

    Seems that this is some weird scaling issue. Our textures are large and at a high resolution, but we seem to have our atlas layout accepted. The Atlas editor makes it look like our textures have been scaled down, but my guess is that this is just not the case.

    We will resize our textures and cross our fingers we have no more issues!

    Thank you all!
     
  3. hidekihanida

    hidekihanida

    Joined:
    May 30, 2012
    Posts:
    5
    Hi , I want to set animation's dynamic framerate . Can I set?
     
  4. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    You sure can. Try something like this:

    Code (csharp):
    1.  
    2.  
    3. SmoothMoves.BoneAnimation knight;
    4.  
    5. void Update()
    6. {
    7.         if (Input.GetKeyDown(KeyCode.F))
    8.         {
    9.             knight["Stand"].fps = 1.0f;
    10.         }
    11.  
    12.         if (Input.GetKeyDown(KeyCode.G))
    13.         {
    14.             knight["Stand"].fps = 10.0f;
    15.         }
    16. }
    17.  
    18.  
    [EDIT]

    Also, be sure that you set the FPS on the BoneAnimation component, not the Animation component. Smooth Moves will translate your FPS to the appropriate speed used by the plugin automatically for you.

    [/EDIT]
     
    Last edited: Aug 29, 2012
  5. ElBueno

    ElBueno

    Joined:
    Jul 4, 2011
    Posts:
    19
    Has anybody created any PlayMaker actions for texture swapping?
     
  6. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    I'll add that to my TODO list.
     
  7. ElBueno

    ElBueno

    Joined:
    Jul 4, 2011
    Posts:
    19
    Haha, you're the best. I'll let you know if I end up beating you to it. :p
     
  8. hidekihanida

    hidekihanida

    Joined:
    May 30, 2012
    Posts:
    5
    Thank you for reply!
    I'll try it.
     
    Last edited: Aug 30, 2012
  9. danboutros

    danboutros

    Joined:
    Mar 26, 2012
    Posts:
    32
    HORIZONTALLY FLIPPING ANIMATIONS IN A MEMORY SAVING WAY

    Hi Echo!

    Is there a chance I can flip animations in a way where I don't have to redraw the same art and burn more memory?

    For example - a left facing and right version of the same anims.
     
  10. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    @echo, can you add "do not inherit rotation/position from parent" feature. it is very important for animation. for example; assume that you have head and chest.chest is parent of body. whenever you move head moves with it. if head uses chest rotation you must do corrections. generally (not always) head preserve its rotation while chest rotate. also using just rotation of parent can supply some additional features. it can be implemented just using 2 check boxes and 2 if statements, but it will make many people's life easier :)
     
  11. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    @echo can you add "copy and paste", "duplicate bone with children" and "mirror bone with children". i want to use these feature to duplicate left part of my character and use its horizontal mirror for right part of my character. my hierarchy like chest->upperarm->lowerarm->hand
     
  12. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    @echo i have position editing problem.my hierarchy like chest->upperarm->lowerarm->hand. after i changed x scale of upperarm as -1, positioning arrow of lowerarm works reverse. when i try to move it to the right lower arm moves to the left. then i used image scale. i think local scale has positioning child problem.

    Edit:I can not select a bone that has local x scale=-1 on editor window. i have to select it from hierarchy window.
     
    Last edited: Sep 2, 2012
  13. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    @echo can you add expand/collapse feature to bone hierarchy window?
     
  14. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    @echo atlas image is compressed default for ios. compressed view is not good. is not it better to make it non compress default?
     
  15. Mars91

    Mars91

    Joined:
    Mar 6, 2012
    Posts:
    572
    Hi
    I created the Atlas and New Bones Animation but nothinbg is displayed in the editor.
    I'm getting this error:

    m_IsVertexBufferMapped
     
  16. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    What I do is just rotate the BoneAnimation's gameobject transform along the y axis 180 degrees. The quads will still render in the same order based on the depth, so it will look like a mirror image.
     
  17. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    If only it were so easy :) Unfortunately, two checkboxes is just an interface change. There would be many, many data and process changes to accommodate this. I would suggest moving your bone that you don't want to inherit position/rotation away from the parent. This way you can set the bone's position/rotation manually without being affected by another bone.
     
  18. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Copy/Paste is already implemented. Just use Ctrl+C and Ctrl+V just like you would in any program. You can also set the properties that are copied by going to the settings and toggling on and off the properties you are interested in.
     
  19. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    When you scale a bone, all of its child bones are scaled as well. If you scale negatively, then you will get reversed properties on all children. If this is not desired, try scaling the image instead of the local scale.
     
  20. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    This is on my to-do list.
     
  21. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    This is Unity's default setting. You can easily override this to anything you wish after the atlas texture is generated by using the Inspector. Smooth Moves will preserve your changes for the next time it builds the atlas.
     
  22. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    I will need to see your project to tell you what is going on. If you send your zipped project to: support@echo17.com I'll have a look.
     
  23. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    i think logic for "do not inherit rotation" is; just subtract parent's rotation from local rotation. is not it just for one line :) do i miss something?

    for head bone i want position inheritance, not rotation. so if there is no inheritance there will be some work. it is called "counter animation". so this feature is time saver.
     
  24. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    ctrl+c and ctrl+v doesnt work? i am on bone animation editor window. i try to copy a bone from hierarchy panel. then i try to paste it to any bone. it doesnot work.i have the latest smooth moves.
     
  25. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    yes i have reversed properties but it i a visual editor. i try to drag it visually.visual left should be left.

    also i cannot select it from visual editor.
     
  26. Mars91

    Mars91

    Joined:
    Mar 6, 2012
    Posts:
    572
    Email not working. Pm sent
     
  27. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    @echo please watch this video; http://www.blenderguru.com/videos/introduction-to-rigging it is about 3d rigging. if you add inverse kinematics (IK) and some constrains features you can sell this extension as Smooth Moves Pro. i will be the first customer of it :)

    assume you have this hierarchy; chest->upperleg->lowerleg->foot. when you move chest down leg parts automatically rotate and leg will not move. can you add this?
     
  28. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Sorry about that. Looks like I'm having some trouble with my hoster.
     
  29. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    IK is on my TODO list.
     
  30. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    Great ! i am waiting good news from you :)
     
  31. Mars91

    Mars91

    Joined:
    Mar 6, 2012
    Posts:
    572
    New PM sent ;)
     
  32. Mars91

    Mars91

    Joined:
    Mar 6, 2012
    Posts:
    572
    Hi
    I need your help how can I maintain the depth set to a bones for all keyframes?
     
  33. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    I answered your PM, but I'll repeat here in case anyone else has this question:

    After the first depth key is set, you don't need to add any more depth keys if you want to maintain the same depth. Just be sure the depth is set the same in all animations if you want it to be consistent across animation clips.

    One easy way to do this is to duplicate the first keyframes when creating a new animation. This will set up your animations in a consistent way. You can see this in my user manual in section 5.6 under "Duplicating a Clip".
     
  34. blaze

    blaze

    Joined:
    Dec 21, 2011
    Posts:
    211
    echo17,
    I'm using a sphere collider in the head of my stickman. Then, how can I configurate the "Collision Detection" of the sphere collider to be "Continuous Dynamic"?
    I can do this in the inspector, in already created gameObjects, but I need to config this before the stickman is created.
    Could understand me? I need to preconfigure this, to be in my prefab.

    I need this for the bullets:
    "This is the slowest collision detection mode, and should only be used for selected fast moving objects."
    http://docs.unity3d.com/Documentation/ScriptReference/CollisionDetectionMode.ContinuousDynamic.html
     
  35. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Looks like I need to add some settings for the rigidbody to the keyframe for the collider. I'll put this on my TODO list.

    [EDIT]

    For now, you can modify any of the rigidbody settings manually after the BoneAnimation has been created. You can do this with code like:

    Code (csharp):
    1.  
    2.  
    3.     public SmoothMoves.BoneAnimation boneAnimation;
    4.  
    5.     void Start ()
    6.     {
    7.         Transform t = boneAnimation.GetBoneTransform("Weapon");
    8.         Rigidbody r = t.GetComponent<Rigidbody>();
    9.         r.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
    10.     }
    11.  
    12.  
    [/EDIT]
     
    Last edited: Sep 4, 2012
  36. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Actually, after re-reading your post, it seems you may be putting the continuous dynamic rigidbody in the wrong location. Looking at the Unity docs, this mode should only be used on fast moving objects. So instead of putting it on your character's head, you could instead attach a rigidbody to whatever fast-moving objects are colliding with it (bullets or whatever). The collision should still be captured by the head since the bullets are being processed at a higher rate.

    Then again, putting this type of collision detection on many bullets may be worse performance-wise than just having it on the head, so my example code in the previous post might be the better way to go.
     
  37. blaze

    blaze

    Joined:
    Dec 21, 2011
    Posts:
    211
    Awesome! Works like a charm!

    Here is what I have until now. I'm only getting collision in the head, after I will make the head get bouncing in the level. :p
    http://stickscarnage.jeanbrito.com/stick0.10/index.html

    I will need some help with the AI. If I send you a PM, you can help me with some suggestions?
     
  38. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Very cool! Thanks for sharing.

    I'm afraid my AI skills are lacking. In my games the enemies just come straight for you (no pathfinding) and fire when in range. Very plain. I imagine there are lots of threads here that could help you out with that, though.
     
  39. blaze

    blaze

    Joined:
    Dec 21, 2011
    Posts:
    211
    I bought Blob Berserk to see how do you do that game using the Swarm Object Manager.
    I bought the Swarm Object Manager too. I will use it in this game that I'm working.

    Someday do you will update the Blob's game?

    I would like to know how do you made the helicopter, cops and tanks AI.
     
    Last edited: Sep 4, 2012
  40. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Basically, each enemy does this:

    1) Look to see if the player is the minimum distance away to be "seen".
    a) If the player can be seen, then move toward them.​
    b) If the player can't be seen, ignore them, randomly changing direction or continuing in the same direction.​
    3) If the enemy is within its minimum firing range, then attack.

    The cops are even simpler, they just drive around randomly, not attacking or helping anyone. They are more just for decoration (and pure smashing fun of course) :)

    I have an enemy manager that updates all the enemies every so many frames so that it isn't constantly processing.

    This is extremely basic AI and does not provide an intellectual challenge. The strength of the enemy is not in its AI, but in the sheer overwhelming power if you are not careful. It forces you to attack, evade, and keep up your strength by eating more humans.
     
  41. blaze

    blaze

    Joined:
    Dec 21, 2011
    Posts:
    211

    Attached Files:

  42. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Looks like you have compression turned on for the images. iPhone compression is much worse than desktop compression. If you want to get rid of this you have two options:

    1) Turn off compression (set it to RGBA or something similar) in the inspector for the atlas texture.
    2) Increase the size of your source graphics, rebuild the BoneAnimations, and then set the scale import on the BoneAnimationData to compensate for the larger animation.
     
  43. ddf

    ddf

    Joined:
    Jul 9, 2011
    Posts:
    54
    Hey echo17, great plugin!

    I've a question you may or may not be able to help with. I'm currently working on a music app, so there is sound going pretty much all the time. I'm also using SmoothMoves to do character animation. When I run a level, I periodically hear glitches in the audio, so I profiled to see if I could figure out what might be causing it. The result was I can see I'm running around 45fps, but every now and again there is a spike to just under 30fps that coincides with the audio glitches and the thing that's at the top of the list is AnimationManager.LateUpdate(), which I think is a class inside of SmoothMoves_Runtime.dll. That function takes about 1-4ms on average, but when there's a spike it takes 20ms. Do you have any idea what might cause occasional performance spikes like that?
     
  44. dasbin

    dasbin

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

    I have run across a problem or potential bug with the BoneAnimation.SwapMaterial() function.

    Basically, I have an animation that uses only one atlas and material. I want to script in material swaps between a few different materials (which all use the same atlas that I don't want to duplicate - they just have different shaders).

    I am doing it like this now:

    So the idea is just to swap from whatever the current material is to the new one (Smooth Moves API doesn't seem to have a "get current material" function so I have to do it from the Renderer component of the GameObject).
    However, when going from an already-replaced material to a new material, Unity stops with this error:

    Which is why I added the RestoreOriginalMaterials() call first, thinking this would fix it... but it doesn't.

    Any suggestions?
     
    Last edited: Sep 6, 2012
  45. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    There could be a number of things causing the spike, each unique to the animation / scene of your project. The AnimationManager.LateUpdate function is where all the triggers are processed for each of your animations in the scene. It runs every frame, looking to see if animations need to have textures swapped, bones changed depth, colliders turned on, etc. If you have a lot of triggers happening all at once (and more so with multiple animations), then you might see a spike, since there will be an increase in items the manager has to process.
     
  46. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    By design, I made Smooth Moves always swap from the original material assigned in the animation editor. This frees you from having to remember what material you had switched to at any given point. It also lets you code in a modular fashion so that each of your programmers doesn't need to know what material is assigned in order to swap to a new material.

    So to switch to a new material, always swap from the original material you assigned in the animation editor, regardless of what is currently present.
     
  47. ddf

    ddf

    Joined:
    Jul 9, 2011
    Posts:
    54
    Ok, thanks for the info. I suspect it does not have to do with complexity of animations because if I disable all of the animated characters in a level except for one very simple one, I still occasionally get an audio glitch. And given the unpredictability of the glitching, I don't think it's connected to a particular frame in that animation. I had the same problem in the main menu of my app, which doesn't contain any animated characters, and there it was being caused by the Update method of a class I had written. However, when it happened, it was only *one* instance of the 22 that was taking an abnormally long time, and all the method did was very simple:

    Code (csharp):
    1.  
    2. void Update()
    3. {
    4.    // m_text and m_shadow are TextMesh components
    5.    if ( m_text  m_shadow.text != m_text )
    6.    {
    7.       m_shadow.text = m_text.text;
    8.    }
    9. }
    10.  
    I fixed it by removing the Update and instead coming up with a way to notify a text shadow when its parent's text had changed.

    The thing is, I'm pretty sure this glitching is new as of like Unity 3.5, or possibly ike 3.5.2 or something. So I'm not surprised people haven't noticed it, especially if they are making things that aren't focused on music.

    I can put together a very simple test project for you, if you'd like to check it out.
     
  48. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Sure thing. you can send it to support@echo17.com.
     
  49. Mars91

    Mars91

    Joined:
    Mar 6, 2012
    Posts:
    572
    PM Sent
     
  50. Mars91

    Mars91

    Joined:
    Mar 6, 2012
    Posts:
    572
    Question:
    How can I change the animation of a BoneAnimation using the Inspector?
    Why sometime BoneAnimation are displayed only on Play mode and not in Editor?