Search Unity

Smooth Moves - 2D Skeletal Animation

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

  1. Maxime

    Maxime

    Joined:
    Jun 12, 2012
    Posts:
    7
    Hi,

    I can't use SwapBoneTexture and SwapTexture methods.

    First, how my porject is organized:
    • 1 bone animation for a character with 10 clips using about 20 bones from one atlas: "classic_atlas"
    • I want my players to be able to change the clothes of my characters, so I created 2 atlas for 2 cloth groups: "fancy_atlas", "sport_atlas"
    • I wanted to use SwapTexture to change the socks of my character from "classic" to "fancy" for instance, so I wrote:

    Code (csharp):
    1. myBoneAnim.SwapBoneTexture("sock_left", "classic_atlas", "classic_sock_left", "fancy_atlas", "fancy_sock_left");
    2. myBoneAnim.SwapBoneTexture("sock_right", "classic_atlas", "classic_sock_right", "fancy_atlas", "fancy_sock_right");
    3.  
    It doesn't work and I got the following LogError:

    Atlas [fancy_atlas] not found
    UnityEngine.Debug:LogError(Object)
    SmoothMoves.BoneAnimation:SwapBoneTexture(String, String, String, String, String)
    ClothSwitcher:Start() (at Assets/Scripts/ClothSwitcher.cs:12)

    Same error when I tried SwapTexture.

    I triple checked all the names (atlases, sprites and bones). I don't know what to do... Do my anim needs to be somehow linked to other atlases ?


    Note: I first tried in version 1.11.0 but then, I upgraded to 2.0.1 to check if it was corrected but I got the exact same error.
     
  2. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Hey echo,

    just wanted to know what you meant with the "Upgrading to Unity 4 Problem". Currently we are using SmoothMoves 2.0.1 on Unity 3.5.6 and everything works fine. We already accomplished a lot stuff and we really don't want to Upgrade to Unity 4 till the game is released (around mid-next year).
    I hope you won't force the User with an SM-Update to use Unity 4.XX : (
     
  3. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Last edited: Nov 16, 2012
  4. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Yep, that's exactly what I meant. I won't force users to upgrade to Unity 4. I'm going to continue to release SmoothMoves updates on 3.5.6. You can use Unity 4, but you won't have to.
     
    Last edited: Nov 16, 2012
  5. silversteez

    silversteez

    Joined:
    Sep 25, 2012
    Posts:
    12
    EDIT: well, i fixed it by registering it when the player enters his idle state rather than on Start(). i'm still trying to figure out why it doesn't work on Start() since the player is always present in the scene, though...

    hey echo,
    i'm trying to learn how to use user triggers and i've watched your knight youtube vid, but i'm still having a problem that i can't figure out...
    i've set two user triggers (with tags) in my boneAnimation, each on the last frame of an animation clip (trying to use this to track when an anim is finished).
    this is the relevant bits of the code i've got so far:
    Code (csharp):
    1.    
    2.     public BoneAnimation playerAnimation;
    3.  
    4. void Start()
    5.     {
    6.         playerAnimation.RegisterUserTriggerDelegate(AnimCompleteCheck);
    7.     }
    8.    
    9.     public void AnimCompleteCheck(UserTriggerEvent triggerEvent)
    10.     {
    11.         if(triggerEvent.tag == "end_attack_1")
    12.         {
    13.             print ("attack 1 finished");
    14.         }
    15.         if(triggerEvent.tag == "end_attack_2")
    16.         {
    17.             print ("attack 2 finished");
    18.         }
    19.     }
    i'm getting the following error:
    NullReferenceException: Object reference not set to an instance of an object
    SmoothMoves.BoneAnimation.RegisterUserTriggerDelegate (SmoothMoves.UserTriggerDelegate triggerDelegate)
    Player.Start () (at Assets/scripts/Player.cs:74)

    (the line it's referring to is line 5 in the code snippet above)

    everything else is working, by the way. the character animates, etc. it's just this user trigger stuff that's throwing errors.
     
    Last edited: Nov 16, 2012
  6. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Hmmm...without seeing your project, I'm not sure I will be able to figure this one out.

    If you look at the Rise of the Dough minigame, you'll see that I am registering the user triggers in the Awake function of the GUIManager script. If you look at the "New Weapon Available" animation, you'll see that on frame 25 of the "Movement" bone in the "Show" clip I have a user trigger notifying that the animation has completed. This is handled in the function "NewWeaponAvailable_UserTrigger" function in the GUIManager script.

    It could be that you should use Awake instead of Start. Give that a try and see if it helps. If not, go ahead and send me your project via email and I'll have a look.
     
  7. silversteez

    silversteez

    Joined:
    Sep 25, 2012
    Posts:
    12
    thanks for the quick reply and the gracious offer to look through my project for errors! i'll take a raincheck on that and save it for when i'm REALLY stumped if that's alright :)

    i think i figured out what the problem was. in my game, the 'player' is an empty game object with a manager class attached that is always enabled in the scene (it's a puzzle game, kinda sorta) and the boneAnimation it's looking for is always in the scene, as well, but the boneAnimation is disabled when you start the game because it's parented to an inactive NGUI panel (which becomes active when you start a match).

    if i set the panel to active (and thereby enable the boneAnimation) when i press play in the editor, then i can register user triggers in the Awake or Start functions. otherwise, i get the error.

    no biggie - i can work around it. thanks again for the help, echo.
     
  8. astrospoon

    astrospoon

    Joined:
    Mar 23, 2009
    Posts:
    16
    Hey, just curious what the best method is to switch to a new animation, but only when the currently playing looping animation is within a certain frame range. Specifically, I have a character dribbling a basketball, and only want to be able to start the pass animation when the ball is in the frames near the characters hands. Would it be best just to have two triggers in the animation, "PassOK" and "PassNotOK" that toggle some sort of "canPass" variable in the character?

    EDIT: Is there another way to check what frame a currently playing animation is on?
     
  9. silversteez

    silversteez

    Joined:
    Sep 25, 2012
    Posts:
    12
    another question about user triggers (or potentially about unity's animation system, in general):

    i'm placing tagged user triggers on the last frames of my animation clips and trying to build game logic around whether or not they fire. for example, i'll have an enemy play a 'pose' animation prior to attacking (to give the player a chance to react). if the player does nothing, a trigger will register at the end of the enemy's 'pose' animation which sends the enemy into his attack. if the player hits the enemy while he's posing, however, i don't want that user trigger to fire. i'll just go into enemyAnimation.Play("hit_reaction") or something along those lines...

    what's currently happening is that the trigger on the last frame of the enemy's 'pose' animation clip is always firing, even if the 'pose' animation does not reach the last frame. it's as if the 'pose' animation is quickly finishing it's clip (in a split second) before going into the 'hit_reaction' animation.

    one solution seems to be using enemyAnimation.Stop("pose") when the player hits the enemy - then the trigger on the last frame of the clip does not fire.

    my question is: do i have to use a Stop command in this manner to achieve the kind of game logic i'm going for or am i missing something? i'm afraid that adding that extra step will complicate the logic somewhat. i think it will also prevent me from using CrossFades (but so far i'm just using Play to keep things simple)

    Thanks very much!
     
  10. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    That makes sense. The delegate structures aren't initialized until the bone animation's game object is "Awakened", which doesn't happen until it is active. Tricky...I'll have to look into a way around this.
     
  11. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    The method you outlined with user triggers sounds pretty good.

    If you are looking for the frame, however, you can get it by pulling the time of the animation component (NOT the boneanimation in this instance). The boneanimations are set to play 1 frame per second, then I just set the speed factor of the animation to the FPS to make it look like it is running at that speed. So the bone animation's time is actually animation.time / fps, where the animation.time is the frame. Hope that makes sense...

    Code (csharp):
    1.  
    2.  
    3. private Animation characterAnimation;
    4.  
    5. public BoneAnimation characterBoneAnimation;
    6.  
    7. void Awake()
    8. {
    9.     characterAnimation = characterBoneAnimation.gameObject.GetComponent<Animation>();
    10. }
    11.  
    12. public function GetFrame()
    13. {
    14.     return characterAnimation.time;
    15. }
    16.  
    17.  
     
  12. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Hmmm...I hadn't thought about this scenario. Yes, the other animation currently continues to play it's triggers (texture switches, user triggers, etc) unless it is explicitly stopped. I will need to look at stopping it if the play command (with stop same layer, etc) is fired. Thanks for the info, it'll go on my TODO list.
     
  13. astrospoon

    astrospoon

    Joined:
    Mar 23, 2009
    Posts:
    16
    Not sure if this helps, but I ran into this same issue with my ball passing animation. When the pass animation is about half complete, I have an event called PassBall and the ball layer switches to transform only. But after the pass animation ended (it was set to just play once) the ball layer would continue to appear on and off during the idle animation, for which the ball layer should always be transform only.

    -----------------------------

    Also, how is CrossFading handled with Mixed Animations when they end? Specifically, when a player passes the ball, I play a "Pass" animation which only effects above the waist, so you can pass while standing still or running. After the pass animation is complete, I want it to fade back into the underlying (lower layer) animation for the upper body. (Ie, cross fade back into the arms swinging if running, or the breathing torso for idle.)

    If I start a mix animation with a CrossFade(), will it end with a fade as well? Is there a way to call Play() on a mix animation (to start it immediately), but have it fade out at the end? Can I set a trigger, and in code somehow adjust the blend amount of the layer/animation to fade it out myself?
     
  14. astrospoon

    astrospoon

    Joined:
    Mar 23, 2009
    Posts:
    16
    By the way, I know I'm asking a bunch of questions as I get started, but I really want to thank you for such an awesome tool. I've been extremely impressed with what I have been able to accomplish with Smooth Moves in such a short period of time. Really glad I decided to make the purchase.
     
  15. estivador

    estivador

    Joined:
    Nov 5, 2012
    Posts:
    4
  16. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    I'm actually using Unity's animation engine for the playing, crossfading, mixing, blending. It handles all the blending between animation curves as it would with a normal 3D mesh. The thing that SmoothMoves adds is the ability to have triggers fire to make changes to the animation, like texture switches, collider toggling, user triggers, etc.

    So to answer your question about fading, if you can do it with a normal 3D skinned mesh, it will be possible in SmoothMoves skinned meshes as well.
     
  17. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Thanks, glad it is working out for you!
     
  18. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252

    This is amazing! Do you mind if I add your video to my gallery of real world examples on my first post of this thread?
     
  19. Maxime

    Maxime

    Joined:
    Jun 12, 2012
    Posts:
    7
    I added a dummy clip with reference to my atlas but this time I got other errors:

    Could not find texture [fancy_sock_right] in atlas [fancy_atlas]
    Could not find texture [] in atlas [fancy_atlas]
    Could not find texture [] in atlas [fancy_atlas]
    Could not find texture [] in atlas [fancy_atlas]
    Could not find texture [] in atlas [fancy_atlas]
    Could not find texture [] in atlas [fancy_atlas]
    Could not find texture [] in atlas [fancy_atlas]
    Could not find texture [] in atlas [fancy_atlas]
    Could not find texture [] in atlas [fancy_atlas]
    Could not find texture [] in atlas [fancy_atlas]
    Could not find texture [] in atlas [fancy_atlas]
    Could not find texture [] in atlas [fancy_atlas]
    Could not find texture [] in atlas [fancy_atlas]

    Of course, I checked texture name and atlas name. Note: I call SwapBoneTexture only one time but I got 12 times "Could not find texture [] in atlas [fancy_atlas]"
     
  20. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Can you email me your project to support@echo17.com? I'll take a look and tell you what I find.
     
  21. Maxime

    Maxime

    Joined:
    Jun 12, 2012
    Posts:
    7
    I will but I have to strip everything else ;). By the way currently I recreated all Atlases by "parts" and it works (one atlas for the socks, one for the legs, etc...). So my issue should com from my previous atlas. I know it's inefficient, and at the end I will pack all my parts in a minimum number of atlases. I encountered another issue:

    I tried this:
    Code (csharp):
    1.  
    2. boneAnim.SwapTexture("classic_atlas", "classic_sock_right", "blue_atlas", "blue_sock_right");
    3.  
    It's ok, I see my character with a blue sock, but when I try to change from the classic sock, to the blue one and then to the red one - I write either this:
    Code (csharp):
    1.  
    2. boneAnim.SwapTexture("classic_atlas", "classic_sock_right", "blue_atlas", "blue_sock_right");
    3. boneAnim.SwapTexture("blue_atlas", "blue_sock_right", "red_atlas", "red_sock_right");
    4.  
    or this:
    Code (csharp):
    1.  
    2. boneAnim.SwapTexture("classic_atlas", "classic_sock_right", "blue_atlas", "blue_sock_right");
    3. boneAnim.SwapTexture("classic_atlas", "classic_sock_right", "red_atlas", "red_sock_right");
    4.  
    I always see my character with a blue sock ( and i want him to put his red sock ;) ). There is no error or warning in the console.
     
  22. Asse83

    Asse83

    Joined:
    Aug 1, 2009
    Posts:
    169
    I instantiate several instances of an already existing GameObject, these GameObjects have the BoneAnimation, SkinnedMeshRenderer, etc. scripts directly attached to their root. When I play their animations (BoneAnimation.Play()) it seems like they all share one bone data and want to play their animation on it since all meshes are flickering and are strangly transformed.

    Am I doing something wrong?
     
  23. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Swapping is actually much easier than what you are trying to do. When swapping, always reference the ORIGINAL atlas and texture that you want to swap from, regardless of what it actually is at the moment. This frees you from having to keep track of what you currently have assigned.

    Have a look at the minigame where the chef's weapon is being swapped for an example.

    [EDIT]

    Nevermind, I just saw that your second set of code is correct. I'd have to see your project to give you a good idea of what is happening.

    [/EDIT]
     
    Last edited: Nov 19, 2012
  24. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    I'd have to see your project to give you a diagnosis. You can email it to me at: support@echo17.com
     
  25. estivador

    estivador

    Joined:
    Nov 5, 2012
    Posts:
    4
    no problem man. it will be cool. i'm now trying to do other loops https://www.dropbox.com/s/o813jdb41v627qc/zombie2.mp4 like run, idle and take a damage, but.. the damage looks more like the zombie dancing a lady gaga's song... but anyway, still impressed with this tool.
     
  26. Maxime

    Maxime

    Joined:
    Jun 12, 2012
    Posts:
    7
    I works only when I call RestoreTextures() before reswapping. By the way, I read the API spec and didn't found any function like "RestoreTexture(string atlas_name, string texture_name)" (only one with the bone name but i don't have it).
     
  27. Asse83

    Asse83

    Joined:
    Aug 1, 2009
    Posts:
    169
    Ok, the problem is that I'm instantiating (cloning) an already existing GameObject, when I instantiate from a prefab everything works fine.
     
  28. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    That could be an entire game in itself: "Zombie Dance" :) I've put a link to your work on the first post, thanks!
     
  29. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Yeah, sorry about that. Looks like the API docs are a bit behind. There are two functions you could use to restore a texture for an animation clip, and restore for all animation clips (regardless of bone):

    RestoreAnimationTexture
    RestoreTextures
     
  30. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252

    I'll be observing the American Thanksgiving holiday with my family, so I'll be out of touch for a few days. Be back soon!



     
    Last edited: Nov 23, 2012
  31. Maxime

    Maxime

    Joined:
    Jun 12, 2012
    Posts:
    7
    Thank you.

    Have great holidays !
     
  32. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,633
    Hi guys, apologies if this is not the right place to ask, please re-direct me. Anyway I bought smooth moves and I love it, im trying to build my first idle animation, my problem is that I have some strange lines appearing where the parts of my character are attached.

    So here is a screenshot of my guy built in smooth moves:
    http://www.radiantsilverlabs.com/gazpix/fraiser/test1.jpg

    As you can see he looks almost perfect, but there are lines on his ankles, arms and most noticably where his pants join his thighs. Now if you look at my source atlas, there is no such line. The source images given to me btw were 8 bit/256col pngs (we are trying to save memory, not sure if I should just use 24 bit? and maybe it would fix it?)
    Atlas: http://www.radiantsilverlabs.com/gazpix/fraiser/littlecrew.png

    Here is an extreme crotch shot to showcase my issue, this line I have no idea where its coming from: http://www.radiantsilverlabs.com/gazpix/fraiser/extremecrotchshot.jpg

    And finally, curiously I DO see this line in my Atlas editor, even though im quite confident there is no such line on the source images:
    http://www.radiantsilverlabs.com/gazpix/fraiser/wherethelinecomingfrom.jpg

    Can anyone shine any light on this?

    Thanks very much,
    Gaz.

    UPDATE: So my artist re-drew the parts in question and nothing changed, I even saved them as 24 bit pngs, yet still the lines are there, it appears that somehow the edges of transparent images are given a line when you load them into the atlas editor?? There must be a way around this!? Otherwise I dont see how anyone ever uses Smooth Moves to make their characters? Please help! :)

    SOLVED! OK So I found out that if you draw anything while photoshop has the image mode set to "Indexed Color" then these strange lines appear when you save, BUT if you work with the image mode as "RGB Color" the lines dont appear! :))

    Im still having to do some feathering to get it to blend properly, so any further suggestions would be good, here is a video of me attempting to fix the lines http://www.youtube.com/watch?v=VHUsYLtVVEU
     
    Last edited: Nov 22, 2012
  33. yls

    yls

    Joined:
    Apr 13, 2012
    Posts:
    197
    Hi, first i have to tell that i'm a Smooth Move Noob (since yesterday).

    I was dealing with the tutorials with my own simple model (a body, tail, head and a tail). I have an animation that works just fine in the editor, but once it's played in the game the tails seems to be disconnected from the body (while the head and hat move just fine). What should I correct ?

    My issue : Editor on the left, Game on the right


    Any idea ?
    Best regards
     
    Last edited: Nov 21, 2012
  34. Sundaerae

    Sundaerae

    Joined:
    Nov 19, 2012
    Posts:
    5
    Does the problem with AnimationEvent on Flash export still exist in the Unity 4 release build? (4.0.0f7)
    Really interested in this since smooth moves on flash export = flash editor on 3D objects
     
  35. danthat

    danthat

    Joined:
    Aug 1, 2012
    Posts:
    25
    Hm, I'm getting this same issue. I've tried referencing it, as above, but it's still not finding the new Atlas.

    I just upgraded to SM2, with Unity4. Interestingly, if I click on the little circle next to Atlas in the editor, it doesn't find any atlases, even though there are several. It just says "none", and I have to drag the Atlas over into the editor.

    Still looking into it, but any advice would be much appreciated.

    EDIT: seem to have fixed it. Not entirely sure which of these steps was responsible, but here's what I did.

    SmoothMoves-> Tools -> Control Panel Force Build All Data
    Added a new reference to the Atlas in the Animation Editor under a new bone
    With the editor open, rebuilt the Atlas
    Hit Play, and this time I got a progress bar about "updating bone animations" which didn't happen before. Worked fine.

    Not sure what to suggest happened, but there you go. Seems SmoothMoves maybe wasn't building properly?
     
    Last edited: Nov 22, 2012
  36. IPete2

    IPete2

    Joined:
    Oct 8, 2012
    Posts:
    10
    Hi Smooth Moves users and potential users,

    Just a quick note to let you know about our Licensed TV Show based game which has recently been released, called "Poppy Cat" based on the pre-school tv show of the same name, which heavily relied on SmoothMoves to recreate the animation seen in the tv show.

    Here's the links

    - in the USA and Canada https://itunes.apple.com/us/app/poppy-cat/id569224618?mt=8
    - in the UK and everywhere else https://itunes.apple.com/gb/app/poppy-cats-party-treasure/id566339923?mt=8


    Made in Unity using SmoothMoves - Echo17 was instrumental in helping us get through the three month development period with ease, and his tech support was very rapid and extremely important in keeping our development path fluid. There were a couple of hairy moments but with his help we made it through just fine! ;)

    The result says it all so please check it out and give us feedback. If you have pre-school children this is a wonderful App - please enjoy.

    This App is about to go on promotion so standby from Monday it will reduce its price to tier 1 for two weeks.


    Peter M. Caddock
    Head of New Technologies
    Studio Liddell, UK
     
  37. dasbin

    dasbin

    Joined:
    Jan 14, 2012
    Posts:
    261
    Hi,

    I'm having a big issue with the way the new auto-build / Force-Build works on prefabs.

    Basically, I use a lot of instantiated prefabs in my scenes, but Smooth Moves really breaks the way prefab links work now (this was fine before the big update). Most of my instantiations have modifications of some kind done to them - so I use prefabs to instantiate 100 copies of something, then set about making some separate modifications to many of the instantiations themselves, which (intentionally) breaks the prefab link.

    Now, whenever Smooth Moves forces a rebuild of animation data, it forces all instantiations of the prefab to re-link to the original prefab and revert to all original settings, variables, and modifications. So I lose all my work on every level after every rebuild.
    This doesn't seem like a good way of doing things... and in fact, is quite a deal-breaker on my current project where I am using this process in spades.


    I also have big issues with my animations residing on child objects nested inside prefabs, which I know we are not supposed to do, but I have to. There is no other logical way to control multiple animation objects from within a single moving transform, which is required for particularly complex objects. I don't understand exactly why this works the way it does, now - the old version worked fine with child prefabs - it just wouldn't build within them, I'd have to create an actual instantiation of the object, build the animation, then apply to the prefab. This isn't even an option anymore and it just seems to break everything - could you consider at least adding a checkbox for "ignore prefabs in build" or some such thing?
     
    Last edited: Nov 25, 2012
  38. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Glad you figured it out and thanks for posting your solution here. Artifacts in the images are generally caused by source file settings or the translation of image data when Unity imports your assets. It's tricky to get it all looking good. :)
     
  39. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Be sure you have more than a single keyframe for the position value of your tail. SmoothMoves will not generate animation curves if you have only a single keyframe (by design -- allowing you to mix without forcing values into each animation clip).
     
  40. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    SmoothMoves will not currently work on the Flash platform. This is actually a bigger issue than just the animation events. Flash supports a very limited .NET subset of functions and structures. SmoothMoves uses .NET heavily, so I don't see there ever being a port to that platform.

    FYI, SmoothMoves does work in the web player if your target is online.
     
  41. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Not sure what would cause this set of circumstances. I haven't encountered that before. Thanks for posting your solution for others :)
     
  42. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Thanks for posting IPete2! Excellent works and congratulations on the product launch!
     
  43. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Unity won't let you modify prefab data directly. Instead, I have to instantiate, update, apply back to the prefab, then delete the instantiation. In order to do that, I need to re-apply any broken prefab links. Previous versions of SmoothMoves didn't update prefabs at all (all animation data was generated at runtime -- very costly time and memory wise).

    I'll look into ways of possibly re-breaking the prefab connection if it is possible.

    Unity does not allow devs to see beyond a prefab's first level of child objects. As in the above statement, I have to instantiate in order to modify the prefab data. Nested children cause problems when rebuilding the skeleton and preserving child objects attached to bones.

    As an alternative, you can place each bone animation in a separate prefab. In your "master" or "parent" prefab, you can reference these child prefabs and instantiate them at runtime. This gives you the final product of having a nested animation structure at runtime.
     
  44. dasbin

    dasbin

    Joined:
    Jan 14, 2012
    Posts:
    261
    Thanks for the reply. I understand the (rather silly) limitations of Unity on nested prefabs, so I get that the way you're handling it now is probably the best compromise in most cases.

    However, it seems that to allow the option of "ignore prefabs when building" (whether auto or forced) would actually instantly solve *both* the issues I'm having, and I can go back to updating my instantiations manually, then applying that instantiation back to the prefab when (and only when) I want to. The only thing this would really break is nesting children on bones (which, personally, I don't have to do) - so you can potentially leave that decision up to the user rather than force the prefab updates and re-linking. Would you consider adding this?
    Thank you again.
     
  45. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Sounds reasonable enough. I'll add it to my TODO list to consider.
     
  46. kenwong

    kenwong

    Joined:
    Jan 22, 2012
    Posts:
    24
    For future reference - the reason this occurs is that your opacity channel is anti-aliased, making some pixels partially translucent. For a PNG, a 50% translucent pixel is combined with a matte color to figure out the true color of that pixel. For normal images this matte color is white, for an atlas it's black. That's where the dark fringe comes from. To avoid this problem you can use a format that has separate RGB and alpha channels like TGA, or a PSD as long as the bottom layer is flattened. I imagine you can search for tutorials on 'Photoshop alpha matte'.

    I'm not really sure why color mode solves this! Not really sure why you're using indexed color in the first place, as Unity can't take advantage of this type of compression.
     
  47. wolfgang-almeder

    wolfgang-almeder

    Joined:
    Aug 6, 2012
    Posts:
    6
    Hi echo17, i dont know if this the correct place to ask this if not please tell me where to do it .

    i am developing a 2d game that primarily is expected to be released on ipad (2,3) first where using 2d Toolkit for the animations, but given the type of game where developing (bunch of animations and characters) and the time we have to complete it, we decided to buy Smooth Moves (not with my unity3d account) so our artists just draw the characters cut them into pieces and animate it.

    Now my question is: Is expensive to instantiate a bone animation ? because i notice a lag when i do it in my compiled game for ipad, and not only there in my unityeditor the FPS drops to 3 to 5 frames :-o note: the maximum number of gameobjects that i am currently instantiated are 20, each one of my gameobjects have a bone animation as a child, and some other scripts like a FSM.

    Any clue of what is causing that ? for me its weird :confused: because i didnt see that lag when instantiating the same amount of GameObjects using 2dToolkit.
    Thanks in advance! ;)
     
  48. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    I generally try to avoid instantiating any object at runtime (except at the start of the scene) on mobile devices. The memory allocation can take some time and use processing power.

    SmoothMoves animations are much more complicated than 2DTK sprites, the difference being that SmoothMoves creates skinned meshes complete with animation curves, triggers, etc., where 2DTK sprites are a simple four vertex mesh.

    My advice would be to instantiate your objects at the start of the scene and activate / deactivate as needed. Also, please be sure you are using 2.x version of SmoothMoves. The older 1.x versions did a lot more calculations at runtime which can slow down instantiations.
     
  49. echo17

    echo17

    Joined:
    Nov 24, 2011
    Posts:
    1,252
    Version 2.0.2 has been approved

    Bug fixes:
    • If a bone animation is inactive when registering user triggers, collisions, or collider triggers, then the registration structures will now properly initialize upon registration.

    Features:
    • Added unregister functions for the user triggers, collisions, and collider triggers.

    I've updated the API documentation with the new unregister functions. You can find their documentation here:

    API Docs: BoneAnimation
     
  50. wolfgang-almeder

    wolfgang-almeder

    Joined:
    Aug 6, 2012
    Posts:
    6
    Ok, thanks for your fast response, i am already doing the instantiate at the start of my scene deactivating and activating when i needed, but no luck at all, i see the same lag, and also when i activate the object and all its childrens i see a little lag not much as in the instantiate but its there, im going to update my smooth moves version now :) by the way how do i know wich version i have :S

    And other thing i do remember to have seen a video of an early version of smooth moves where you put various knights (dont remember how much) and compiled into an ipad 1 i am right ? so i know that its posible to have multiple animations on scene.