Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    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,205
    You'll get the same performance from a user trigger as a collider switch since they happen in the same process. The limitation is in Unity's processing of the skinned mesh animation curves.
     
  2. ElBueno

    ElBueno

    Joined:
    Jul 4, 2011
    Posts:
    19
    Actually, I just implemented this technique now and it worked perfectly! :D

    Thank you for your help! I really appreciate how responsive you are about supporting your product. :)
     
  3. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,205
    Interesting, it must be something to do with the physics engine for the colliders that causes it to not respond with high velocity objects. Glad the user trigger worked out for you.

    No problem!
     
  4. Threeli

    Threeli

    Joined:
    Jul 9, 2012
    Posts:
    12
    Just wanted to pop in and say I purchased your wonderful product. I've been stalking this thread since it was one page a nd your work ethic really is inspirational. I hope it's selling well. When I have something to show (having used it) I'll do just that - but until then I wanted to comment on your excellent work/support.
     
  5. pushbyte

    pushbyte

    Joined:
    Apr 1, 2012
    Posts:
    9
    I would also like to drop in and say how much I love this product. Worth every penny. A couple of questions about:

    1.) Would it be possible to implement changing multiple keyframes at once? Say I need to shift the position of 3 joints up by 10 units. It would be great if I could select the three keyframes and move them -10. Currently, I have to go to each keyframe and manually subtract 10 from each.

    2.) As a future request, would it be possible to distort the shape of individual components? For an example of what I'm talking about, see After Effects' puppet tool. Instead of having individual components that move around on a hinge, there's a single image that gets distorted around user-defined points.
     
  6. kdbguy

    kdbguy

    Joined:
    Aug 29, 2011
    Posts:
    15
    Hey Layne, no problem, go for it. ;)

    They're not that impressive though, most of them were just rushed. Once I get better animations done, I'll post them here. Hopefully, it helps convince some people.
     
  7. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,205
    Thanks, Threeli! Appreciate the kind words and your support!
     
  8. echo17

    echo17

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

    I had originally planned to have this in place, but the trouble is that each keyframe may correspond to a different bone somewhere in the hierarchy. Moving -10, for instance would have to either move -10 on each bone's local axis, or -10 in world coordinates, which may get really confusing and non-intuitive. I have it somewhere on my list to look for a better alternative, but I'm not sure what that would be at this point.

    Unfortunately, distorting the shape of a quad would require a bone for each vertex, effectively multiplying the bone count to 8 times its original (i use a separate bone for scaling the image on top of the local scale). This would blow up the memory usage to a point where the animation would seriously impact performance. It would also require a complete rewrite of the animation editor to handle vertex manipulation. Sorry, but this one is very unlikely in the near or mid future. I can always add it to my list :)
     
  9. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,205
    Thanks, Leo! I made the changes to the thread's home page.
     
  10. pushbyte

    pushbyte

    Joined:
    Apr 1, 2012
    Posts:
    9
    Makes sense. I was mainly thinking about ways to animate hair or other organic materials that don't look right with a simple hinge-based solution. I can always just animate them by hand and swap between frames like a standard animated sprite, though it would be handy to have simple distortion capabilities. Anyways, thanks for the taking the time to explain the difficulties involved!
     
  11. Tuhljin

    Tuhljin

    Joined:
    Jun 23, 2012
    Posts:
    12
    I've been considering picking up Smooth Moves for use in my project, but I have a few questions.

    First, does it only do skeletal animation, meaning I'd have to get something else going to handle more standard sprite animation?

    Second, I'm going to have a lot of characters moving around the scene (not sure exactly, but the upper end could exceed 100 simply-animated characters at times) but I read a post earlier in the thread saying that it's best for handling a smaller number, perhaps one dozen or so. Is that a general limitation, or just a recommendation since SM is often used for mobile projects? (My project is designed for the PC.)

    Finally, would SM work well for a highly moddable program, allowing users to supply new images and animations? Two related questions: Can images be loaded at runtime -- with all the "heavy lifting" stuff handled well: Atlasing or whatever else is done to keep performance high? My program is going to include an extensive modding system so users will be supplying their own images. Also, can animations be configured programmatically, at runtime? It'd be nice if the modding system allowed custom animations, though there'd naturally be limits to what can be done (so many humanoid shapes and multi-legged beasts of various sizes would be supported, but it won't be entirely freeform -- unless that'd be possible and not too difficult to pull off, that is).
     
  12. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,205
    It can do a combination of skeletal and traditional sprite animation. I would not use the editor for an animation that is ONLY sprite animation, since that would be overkill. But if you want to mix, then it is perfect for that. See my tutorial on mixing textures where I have a sprite animation (blinking the knight's eyes) running on top of whatever skeletal animation is playing beneath:



    For a PC, I don't see this limitation being a problem. You are correct that having that many animations running on a mobile device would definitely slow it down. You can think of Smooth Moves animations like an animation you'd create in a modeling package such as 3DS Max. Skinned meshes are smooth and wonderful, but can eat up a lot of processing on mobile devices.

    That would be tricky. The texture swaps are currently set up at design time, so the users would not have access to this. You could use material swaps, but that would require the user to set up an atlas(es) based on the same layout as the atlas(es) used in your animation. Not sure if the current version of Smooth Moves would handle user mods very well

    With the current version of Smooth Moves, I would not see this as very viable. It may grow to accommodate something like this in the future, but right now it is probably not what you are looking for.

    As long as you don't supply animation curves to a property, you can overwrite the property values at runtime. In SM, you have to provide at least two keyframes for any property (position, rotation, scale) to generate an animation curve and be animated. If you do not provide at least two keyframes, then no curve will be generated and you can freely position, rotate, or scale depending on which property(s) is left with only one keyframe.

    Mostly this feature is utilized so that you can manually rotate a head bone to look at another object, for instance. Or you could position an arm bone so that it tracks the mouse and fires in that direction.

    Making an entire animation at runtime would be daunting however.

    To sum up: for runtime customization of animations, Smooth Moves is probably not the right plugin for you. You could probably make some things work, but it would definitely cut down on its primary purpose of trying to speed up development.
     
  13. Tuhljin

    Tuhljin

    Joined:
    Jun 23, 2012
    Posts:
    12
    Alright, thanks for answering my questions. Too bad things can't be done so easily at runtime. I've yet to see a 2D animation tool for Unity that lists such a thing among its features. I really hope I don't have to reinvent the entire wheel, so to speak, just because the other wheels are slightly "off".
     
  14. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,205
    Smooth Moves 1.10.1

    Last week had two new releases of Smooth Moves. The notable feature added was the ability to completely turn off a bone from being displayed at runtime (not just in the editor). You can set this visibility in the editor or at runtime with the new function "HideBone" (which shows and hides a bone based on the hide parameter).



    To toggle through the different states, just keep clicking the eyeball / closed eye / red x.

    • Open Eye: Bone is visible at runtime and the editor
    • Closed Eye: Bone is visible at runtime, but not in the editor
    • Red X: Bone is not visible at runtime or the editor

    Other fixes / features:
    - Removed HideAnimationBoneTexture and HideBoneTexture functions
    - Added IsBoneHidden function to return whether a bone has been set hidden manually or through the animation editor
    - Fixed SetAnimationBoneFrameTexture in the BoneAnimation class to properly create a trigger frame if no frame exists.
     
  15. hafizmrozlan

    hafizmrozlan

    Joined:
    Jun 15, 2012
    Posts:
    117
    This is great!

    I've played with SmoothMoves and make some walk animation. While I experimenting with the knight to walk facing left, not just walk backward to left, I thought I have to rebuild the knight by flipping the texture asset one by one and then rearrange the texture depth. But what I found out is when I use transform.rotation(0, 180, 0) on the skinned mesh, it perfectly did what I wanted to do manually, I don't need to flip the texture one by one anymore and the depth is perfectly in order. The drawback is I have to alter my code so the animation won't play inversely but that's not a problem. What do you think about this? Is it legit? Or there is a better and more proper way to do it?
     
  16. srrngames

    srrngames

    Joined:
    Jul 17, 2011
    Posts:
    11
    Hey echo,

    Thanks for continuing to support improve your work :)

    Is there an easy/fast way to do batch operations on multiple bones' fields? We spent quite a while creating our images bone animations, and now it turns out our required sizes for those images have shrunk. If we do a simple resize on the base textures and load up the animation editor, the assets look all scattered, since the scaling down of the images didn't account for the animation's bones needing to be relocated to accommodate the change. We can go in manually, for each animation, for each bone, and scale down the Local Position coordinates with some simple math, and that works... it's just prohibitively slow.

    Ideally, I see the ability to scale any of the local position, local scale, and image scale fields by an arbitrary factor with the touch of a button per animation. That said, my current best option may be parsing the animation .asset file as text, and scaling whatever fields I want by a specified factor. Any suggestions? Do you have any plans to make it easier to deal with resizing assets?

    Thanks,
    John
     
  17. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,205
    You could try setting the local x scale of the gameobject's transform to -1.0f. this will reverse the animation just like rotating around the y axis would, only the direction would still be the same.
     
  18. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,205
    If you are just wanting to scale every texture, you could create a copy of the final atlas' texture and scale that down. I discuss this method in the user manual in "Chapter 8 - Optimizations and Tips", under the section "8.3 Creating Assets for Older Devices".

    You can then adjust the import scale of the animation data if you need to change its physical size.

    User Manual Link
     
  19. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,035
    i want to integrate my game with ngui. i made bone animations with sm. i have orth camera with size:200. i tried to add ngui to display score as label. ngui uses camera size 1. there is a scale difference. what camera size do you suggest for a sm game?
     
  20. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,205
    I always set up a completely different camera for my gui. Just be sure your main camera renders before the gui camera. Having two cameras lets you have independant camera resolutions.

    For your main camera, if your want pixel-perfect ortho set the ortho size to half the screen height. You can keep the ngui camera at whatever it is set at.
     
  21. blaze

    blaze

    Joined:
    Dec 21, 2011
    Posts:
    211
    Echo, I putted this script in the bullet prefab:
    Code (csharp):
    1.     void OnCollisionEnter(Collision collision) {
    2.         Debug.Log (collision.rigidbody);
    3.         Debug.Log (collision.collider);
    4.         Debug.Log (collision.gameObject);
    5.         Destroy(gameObject);
    6.     }
    I created a collider in the head of my stickman. And when I shot in his head, that script shows me:
    null
    stick
    stick

    Then, the script is getting the gameObject, the stick (stickman), but I need to check if the collision was in the head. How can I do to get the bullet collision in the head's collider?
     
  22. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,205
    For collisions (where physics will effect the objects):

    Make sure your head collider has the IsTrigger off. This will create a collision-based collider and not a trigger based collider. You can then trap the collision by registering the collision delegate in boneAnimation to your script. You can filter down the collision results so that you only trap the collision if it hits the knight's head bone and only fires when it enters the collider (otherwise you'd get a lot of collision events for every frame the colliders stay together). There are a lot of other properties you can filter on, but I'll just use these two in my sample:

    Code (csharp):
    1.     public SmoothMoves.BoneAnimation knight;
    2.    
    3.     void Start ()
    4.     {
    5.         knight.RegisterCollisionDelegate(CollidedWithKnight);
    6.     }
    7.    
    8.     public void CollidedWithKnight(SmoothMoves.CollisionEvent collisionEvent)
    9.     {
    10.         if (
    11.             collisionEvent.boneName == "Head"  
    12.             collisionEvent.collisionType == SmoothMoves.CollisionEvent.COLLISION_TYPE.Enter
    13.             )
    14.         {
    15.             Debug.Log ("collided with knight's head");
    16.         }
    17.     }
    if you don't care about the physics interaction of the objects, and only care about whether or not they intersect, then I'd recommend using a trigger instead of a collision collider. This is what I use in my demo when the knight is swinging the sword and it interacts with the target. In this case you'd make sure your knight's head collider's IsTrigger property is true, and instead of registering the collision, you'd register the ColliderTriggerDelegate.

    Note that this method will allow objects to pass through each other.

    Code (csharp):
    1.     public SmoothMoves.BoneAnimation knight;
    2.    
    3.     void Start ()
    4.     {
    5.         knight.RegisterColliderTriggerDelegate(CollidedWithKnight);
    6.     }
    7.    
    8.     public void CollidedWithKnight(SmoothMoves.ColliderTriggerEvent triggerEvent)
    9.     {
    10.         if (
    11.             triggerEvent.boneName == "Head"  
    12.             triggerEvent.triggerType == SmoothMoves.ColliderTriggerEvent.TRIGGER_TYPE.Enter
    13.             )
    14.         {
    15.             Debug.Log ("collided with knight's head");
    16.         }
    17.     }
     
  23. ChaseRLewis73003

    ChaseRLewis73003

    Joined:
    Apr 23, 2012
    Posts:
    77
    Hello echo,
    While my problem isn't with smooth move (working great!) but I'm wanting to add a tool alongside it for certain modifications to colliders and animation data. So far it works really well, but when I attempt to scale the scrollview using gui.matrix it doesn't cull the bounds. How did you create your scene view in smooth move? GUI.ScrollView? something else? any help would be much appreciated as I've been ripping out my hair on this.
     
    Last edited: Jul 25, 2012
  24. sanjodev

    sanjodev

    Joined:
    May 29, 2012
    Posts:
    63
    I'm having a little issue and after looking at it for a bit, I'm not quite sure what the problem is.

    I been noticing that CrossFade between animations can make animations can look a bit glitchy if you are transitioning from a animation that uses different sprites for particular bones (ex. bent arm vs. regular arm), which makes sense because theres no such thing as blending the textures. So I decided to just use the regular Play animation and not CrossFade anymore because I'm not always so sure if the artists will be changing sprites a lot for different animations.

    My issue has to do with some blending I'm noticing even though I never use CrossFade, although I am using the animations in a different way and might not quite understand whats being done. Basically I have a "run" animation and a "turn" animation. The run animation loops and runs on layer 0 with no blending. The "turn" animation can run at any time the character wants to turn, so it can interrupte the "run" animation so to speak. But I dont manually stop the "run" animation and play the "turn". What I am doing is having the "turn" animation on another layer like layer 1 with blending NOT checked either. My hope is that when i play the "turn" animation when the "run" animation plays, SmoothMoves will say hey, "turn" is a higher layer than the "run", so lets give "turn" complete control of the bones. "run" will still run in the background (ex. update its timers), but will have 0% blending. And then when the "turn" animation is done, "run" will have complete control of the bones again, and during the transition, there will be a snapping effect with 0 blending (which is what I want).

    The end result is I do appear to get some blending, and so the transitions looks glitchy because "turn", and "run" uses different sprites for their bones, so theres some awkwardness for a fraction of a second. Is there a way to turn off blending completely via code, or maybe editing the animation settings in a different way to behave the way I just described above? If not, then whats the best way you can think of, but I do imagine you will tell me its with more complex code.
     
  25. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,205
    If you are referring to the Smooth Moves animation editor, then I used just about every tool in Unity's GUI toolkit. It is a combination of every type of control, some nested. I haven't come across the issue you mention specifically. The scaling and positioning of the animation editor's preview window was EXTREMELY complicated and took me about four months to perfect, so it would probably be difficult to explain in anything less than a novel :)
     
  26. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,205
    I think I would need to see your project to get a good sense of what you are describing. The blending of the bone's animation curves is done completely by Unity, using the animation component. The texture switching is handled completely by Smooth Moves and will fire the texture changes for the bones on the highest layer at any given time. If you are transitioning between two different poses, then blending will show some texture switching of both animations while they still play.

    My best recommendation is to go the traditional animation route and not fade or blend any animations that switch poses. Just change to them by using Play. You can create intermediate animations to fill in the gaps between poses (playing them in sequence).
     
  27. Guy77

    Guy77

    Joined:
    Jul 30, 2012
    Posts:
    23
    Edited - moved my post and created my own thread in the proper location.
     
    Last edited: Jul 31, 2012
  28. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,205
    Smooth Moves 1.11.0 Approved!

    The latest features handle better runtime swapping of textures. You can now swap out textures by referencing the name of the atlases and textures. If you are upgrading from an earlier version of Smooth Moves, be sure to rebuild your atlases so that they will have the texture names stored in them. Also, anytime you change your texture's names, you'll need to rebuild the atlas to get the names updated (that's the compromise from having to reference the GUIDs).

    The new functions that swap out textures by name are:

    • SwapAnimationBoneTexture
    • SwapBoneTexture
    • SwapTexture

    I've updated the demo code for the Knight to show how easy it is to swap textures now. I've also removed the texture search and replace components from the demo (you can still use them in your project).

    Here's an example of how to swap out textures:

    Code (csharp):
    1.         // swap out the sword texture on the "Weapon" bone with the axe texture across all animations.
    2.         //
    3.         // Note: We could also call SwapAnimationBoneTexture on each of our animations (or only the ones
    4.         // that we want to change), but this is much quicker since we want the change to
    5.         // apply to all animations.
    6.         //
    7.         // Also Note: we are swapping one weapon with another from the same atlas in this example (Weapons),
    8.         // but you can swap textures across different atlases if you wish. The only requirement for this
    9.         // is that both atlases are referenced in your bone animation at design time so Smooth Moves can look
    10.         // up the atlas by name.
    11.         //
    12.         // Caution: Atlas and texture names are case sensitive. Texture names are not referenced with their
    13.         // file extensions.
    14.         knight.SwapBoneTexture("Weapon", "Weapons", "sword", "Weapons", "axe");
    15.        
    16.         // swap out the sword_swish texture across all bones and animations with the axe texture
    17.         //
    18.         // Note: we could have used the same method above (SwapBoneTexture), but this demonstrates
    19.         // that you can swap a texture across every bone and animation without having to
    20.         // iterate through them all. This is a bit redundant in the case of the sword_swish
    21.         // texture since it only occurs on the Weapon bone anyway, but is useful for illustration.
    22.         knight.SwapTexture("Weapons", "sword_swish", "Weapons", "axe");
    Another example:

    Code (csharp):
    1.             // note that we reference the original texture "sword" and "sword_swish".
    2.             // This way we don't have to keep track of the current texture, only
    3.             // what is was initially.
    4.             knight.SwapBoneTexture("Weapon", "Weapons", "sword", "Weapons", "mace");
    5.             knight.SwapBoneTexture("Weapon", "Weapons", "sword_swish", "Weapons", "mace");
     
  29. ElBueno

    ElBueno

    Joined:
    Jul 4, 2011
    Posts:
    19
    Yay! Thank you so much! This is exactly what I needed! :D
     
  30. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,035
  31. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,205
    Sure thing. I've added a link to the version history in the Links section on the first post.

    The link appears to work for me. Yes, it is the same package that comes with the plugin.
     
  32. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,035
    can i use smooth moves for this; i will generate a sprite. i will add add an unity animation. i will just move sprite from left to right. when i create a cube i can add an animation. when i create a smooth moves sprite i can not move sprite with unity animation.

    Edit: when i remove your spite script i can edit animation parameters. then i add sprite script and choose atlas and image. it works. then again i cannot edit animation. each time i have to remove sprite script and choose atlas and image after i add it.

    Edit: i tried to make it with ngui's sprite feature.it works fine. your script prevents using unity animation feature.
     
    Last edited: Aug 4, 2012
  33. S0ULART

    S0ULART

    Joined:
    Jun 14, 2011
    Posts:
    129
    Hi echo17,
    just wanted to know if it would be possible to implement streching/bending etc like its known from after effects puppet tool, or photoshop's puppet warp.
    I think such an option would let bone based animations look much more organic/natural and would be a great addition. :)
     
  34. pushbyte

    pushbyte

    Joined:
    Apr 1, 2012
    Posts:
    9
    I asked this question previously and he said it would be extremely taxing to do that many points. However, I am curious if it would be possible to select which bones you want to have that extra level of detail, so not every bone would have to be calculated with that many points.
     
  35. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,205
    I wouldn't recommend using Smooth Move's sprites with Unity Animations. If you need to animate sprites, I'd suggest using another 2D plugin such as nGUI or 2DTK. Smooth Moves is mainly for animating skinned meshes.
     
  36. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,205
    Smooth Moves uses one bone per four vertices (quad) for the position, rotation, and scaling). This structure doesn't allow warping or stretching of individual vertices. This was a design compromise due to the fact that if you had one bone per vertex, you'd have a very complex (and memory consuming) skinned mesh. I figured for most people's design needs, the quad based structure would be sufficient.
     
  37. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,205
    That is a good suggestion and would be a nice balance to the flexibility / efficiency issue. It would also require a major rewrite of the data structure and logic, so it would probably be down the road quite a ways if it makes it to the drawing board :)
     
  38. robin_notts

    robin_notts

    Joined:
    Apr 7, 2010
    Posts:
    86
    Help! I've kindof painted myself into a corner. Let me explain: I've built a game with many levels that uses SmoothMove Sprites for the objects you collect in game. I need to be able to store a reference to the image used for each collectable object so that I can display them later (in order) after you've finished the game. At first I thought I could use a bunch of Sprites created dynamically for each object, and change the image to show the correct one. I later discovered that this might not be possible cos of the limited nature of Sprites, so I switched the dynamic Sprites to BoneAnim objects thinking that I could use SwapTexture() to change the image for each one. But, the problem now is that it doesn't seem to possible to get hold of the Atlas/Image information from a Sprite object!

    Is there anything I can do to solve this, without changing the 100s of Sprite objects in my levels to BoneAnim objects? Any pointers would be great. I'm really getting desperate as I reach the end of a very long gruelling project.

    Thanks.
     
  39. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,205
    The Sprite class has public members that reference the Atlas and TextureGUID, called atlas and textureGUID, respectively. The texture GUID is a pointer to the Unity ID of the texture and not the texture name, so you won't be able to call the BoneAnimation's swaptexture functions. You can, however, use the ReplaceBoneTexture function which allows you to specify the guid of the texture. So your code would look something like this (I haven't tested this, so there may be bugs):

    Code (csharp):
    1.  
    2.  
    3. BoneAnimation animation;
    4.  
    5. void SetBoneAnimationTexture(TextureAtlas searchAtlas, string searchTextureGUID, Sprite sprite)
    6. {
    7.     animation.ReplaceBoneTexture("Arm_R", searchAtlas, searchTextureGUID, sprite.atlas, sprite.textureGUID);
    8. }
    9.  
    10.  
    Of course, this assumes you know what the texture GUID is you are searching for to replace in your bone animation. You may need to set up an editor script to store these texture GUID's since you can only use the assetdatabase (which converts paths to GUID's and back again) during design time. If you did this, you wouldn't need to reference the sprite at all. You could just call ReplaceBoneTexture directly:

    Code (csharp):
    1.  
    2.  
    3. BoneAnimation animation;
    4. TextureAtlas searchAtlas;
    5. string searchTextureGUID;
    6. TextureAtlas replaceAtlas;
    7. string replaceTextureGUID;
    8.  
    9. animation.ReplaceBoneTexture("Arm_R", searchAtlas, searchTextureGUID, replaceAtlas, replaceTextureGUID);
    10.  
    11.  
    Here is the script reference to the AssetDatabase: http://docs.unity3d.com/Documentation/ScriptReference/AssetDatabase.html

    Specifically, here are the two functions that convert a path to a GUID and back again:

    [EDIT]

    And while you're at it, you probably don't even need to reference a BoneAnimation if you are storing the texture GUID's. You could just change the sprite by setting its atlas and texture GUID manually by calling SetAtlas and SetTextureGUID on the sprite object.

    [/EDIT]
     
  40. robin_notts

    robin_notts

    Joined:
    Apr 7, 2010
    Posts:
    86
    Hi. Thanks for your help. Your reply is about where I'd got to after looking at your Knight Inspector video. I've since switched back to just using pure Sprites, which seems to work, but I'm getting an issue with unique/seperate meshes, in that all my Sprites end up having the same texture (depending on the last one used). Is there a way to force seperate mesh for each new Instantiated Sprite? Hope this makes sense.

    Thanks again.
     
  41. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,205
    You could try calling the function DisconnectInstance on the sprite object. I haven't tried this at runtime, but I use it at design time to separate the sprite into its own mesh. The code would be something like:

    Code (csharp):
    1.  
    2.  
    3. Sprite sprite;
    4.  
    5. void SomeFunction()
    6. {
    7.     sprite.DisconnectInstance();
    8. }
    9.  
    10.  
    I also forgot to mention in my last post that as of the latest version of Smooth Moves, I am now storing texture names in the TextureAtlas. You can grab the Texture GUIDs from the atlas by calling GetTextureGUIDFromName on the atlas object. Just be sure to rebuild your atlas anytime you make a change to your texture names. Something like:

    Code (csharp):
    1.  
    2.  
    3. TextureAtlas atlas;
    4.  
    5. void SomeFunction()
    6. {
    7.     string textureGUID = atlas.GetTextureGUIDFromName("texture a");
    8. }
    9.  
    10.  
     
  42. robin_notts

    robin_notts

    Joined:
    Apr 7, 2010
    Posts:
    86
    Awesome. All sorted now. For anyone else having a similar issue, I had to make sure I called sprite.DisconnectInstance() before I changed the textureGUID, which makes sense.

    I was aware of the new texture name stuff, which is quite useful.

    Cheers.
     
  43. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,205
    Good catch. Also, I failed to mention that you'll only need to call the DisconnectInstance one time after your sprite is instantiated. After that, you should be able to call SetTextureGUID as many times as you want and it will be in its own mesh.
     
  44. sanjodev

    sanjodev

    Joined:
    May 29, 2012
    Posts:
    63
    Whats your recommendation to handling texture size across various devices of different resolutions. Lets say just from the original iphone, to the latest iphone, and then the latest ipad?

    I learned from working with Smooth Moves so far, that if I built a full mesh animation with various ~64x64 textures for each bone targeting original iphone, and then later on decide to release on IPad, but if I use the original 64x64 textures, then the IPad version of the game would be more pixelated because it has a higher resolution. If doubled the 64x64 textures to 128x128 textures, then the textures will be less pixelated, but then my Smooth Moves animation positioning will be all messed up because of double the texture size.

    So in order to get around that is to not double the size of the textures used to build the texture atlas for each Smooth Moves animation, but to build the final atlas as low res as possible, then when I want to release on a higher resolution, then I need to manually created a texture atlas at 2x the size or whatever. With that in mind, I'm thinking for my characters, I want to work with 256x256 texture atlas sizes, so I would build my animations with that max limit, and if a character needs more textures, then he would just get another atlas. This way, if I need to deploy on IPad, I can retouch the many 256x256 atlases of my game to be 512x512, or 1024x1024, and possibly 2048x2048 if the latest IPad is powerful enough to handle that. This way, I only have to build the Smooth Moves animations once and do not have to worry about texture quality messing up the animations.

    Is this how one would recommend handling different resolutions?
     
  45. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,205
    Check out section 8.3 of my user guide here
     
  46. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,035
    so it is bad news :-( it is not easy to use both ngui and smooth moves together. because of layer, z position and draw call problems i cannot use interlaced layers.
     
  47. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,205
    Sorry you're having difficulty. I can tell you that I use these two plugins perfectly together in my projects without any problems.

    You are probably setting up your cameras incorrectly if you are having layering problems. Keep in mind that you should always have your GUI on a separate camera, which should render last (on top of everything else). You shouldn't try to intermingle GUI elements with your scene, or you'll probably have the issues you're seeing.
     
  48. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,147
    Does Smooth Moves work with "ex2D" and the "Uni2D" plugin?
     
    Last edited: Aug 9, 2012
  49. sanjodev

    sanjodev

    Joined:
    May 29, 2012
    Posts:
    63
    Seems like the same logic except it just starts at a high resolution instead. Also I'm thinking of touching of on the textures directly to maximize the use of pixels especially on the low res versions instead of using the automatic scaling when setting the max size.
     
  50. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,205
    I haven't used the Uni2D plugin, but I don't see why Smooth Moves wouldn't work with ANY plugin. Essentially, Smooth Moves is just creating a skinned mesh, so if you are using Unity, it should work, regardless of what other plugins are present.

    If you mean can it use the atlases created by these tools, then the answer is no. Smooth Moves has its own atlas system, so you'll need to create your atlases using SM for your skinned mesh animations.

    I personally have used Smooth Moves alongside Playmaker, 2DTK, nGUI, SM2, EZGUI, and ex2D.
     
unityunity