Search Unity

[Release][Free] Unity Sprites And Bones - 2D skeleton animation

Discussion in 'Assets and Asset Store' started by TheRealBanbury, Dec 29, 2013.

  1. playemgames

    playemgames

    Joined:
    Apr 30, 2009
    Posts:
    438
    As soon as I do I'll let you know, I'm not sure of the venue yet, but it will be somewhere in LA most likely in January.
     
  2. JamesPomme

    JamesPomme

    Joined:
    Nov 18, 2014
    Posts:
    9
    Hello,

    I'm trying to create a character with elastic arms in a 2D game.

    To do so I create a skeleton using your module and I add a 2D spring joint to one of the arm bones.
    However, I can't use another bone of my skeleton to attach the other side of the spring. Moreover, it seems that a bone child can only rotate (no translation) around its parent, even if its not snap to it.

    Do you know another way to obtain a similar behaviour?
     
  3. TheRealBanbury

    TheRealBanbury

    Joined:
    Dec 15, 2013
    Posts:
    248
    That's how the parent-child-relationship works in Unity. The snapping has nothing to do with it. It just allows to offset the bone from it's parent.
    I'm not quite sure, what effect you're trying to achieve. But joints do work with bones, when used correctly.
     
  4. 8bitCartridge

    8bitCartridge

    Joined:
    Feb 26, 2014
    Posts:
    144
  5. esco1979

    esco1979

    Joined:
    Mar 18, 2014
    Posts:
    138
    PLAYEMGAMES: Thanks for getting back to me. Sorry but I have actually already been waiting on updated vids for your tool for a few months now. I have tried it before, however every time I do I can NEVER get it to work. I just didn't want to be a pain about it, since I saw you already put up that you intended to update the vids.

    I understand if this isn't a priority since it doesn't make you any $$$, and I will say the tool does look awesome. But users having to possibly spend several hours of frustration trying to get something like this to work, when it would be a 10 minute process for you to take screenshots with directions just seems nuts (I'm sure I'm not the only one who has spent hours on it and can't get it to work).

    I tried your suggestion (although somewhat vague) and I have no idea what I have setup wrong still, but it does not work. I am now using the files from github as well.

    CAN ANYONE WHO HAS GOTTEN THIS TO WORK PLEASE ASSIST ME? This is really driving me nuts. I have attached screenshots below of my setup, and all I am trying to do is setup the sprite so I can mesh morph it the same way as is done in this vid with the ears and forehead:


    To keep it simple, all I have made is a skeleton, one bone, and attached the sprite to the bone. I have shown the info for all 3 objects in the screenshots below. I tried using a helper too, but all I could get it to do is rotate the bone and sprite like I could just do using the transform.



     
  6. TheRealBanbury

    TheRealBanbury

    Joined:
    Dec 15, 2013
    Posts:
    248
    I'm sorry, that you're frustrated with Sprites And Bones, but shouting at people won't make it better. Creating tutorials is a time consuming task. Every video took me a whole weekend to create. And we're just two guys with too little time. And yes, we're not making any money on this. If you want quick support, you might want to look at some of the paid addons.

    Everyone who is reading this, is invited to help make Sprites And Bones better. We could really use your help with coding, testing and documentation or answering questions.
     
  7. playemgames

    playemgames

    Joined:
    Apr 30, 2009
    Posts:
    438
    Well I am probably vague because I am not sure exactly what kind of rig you are trying to create. Are you just looking to do a mesh deformation? Are you creating a character made from multiple sprites? The more details you can give me the better. Right now your setup looks fine, but with only one bone, well you cannot do much unless you want to do a single sprite with mesh deformation using control points.
     
  8. esco1979

    esco1979

    Joined:
    Mar 18, 2014
    Posts:
    138
    TheRealBanbury: nobody has yelled at anyone, or been rude to anyone in here. Including me. I have no idea what you are talking about. And tutorials DO NOT take that long to make. I have made them before on several occasions. But again, you guys don't owe us anything and it's a free tool too which is great.

    PlayemGames: I am trying to do this: http://forum.unity3d.com/threads/tr...nding-contracting-effect-on-a-texture.284552/

    I go into detail in the top post. I figure by using 8 bones, on ONE mesh it should work fine. This is what you called a mesh deformation in the old tutorial video. My example has one bone, because all I need is to figure out how to get one working and I can figure out the rest from that of course.

    In short: I am trying to do a mesh deformation. It will use one texture. UNLESS you know of a way to accomplish this effect with a sprite, which would be better (your previous directions said attach a sprite to a bone so I thought I could). I hope I am being clear enough. :)
     
  9. playemgames

    playemgames

    Joined:
    Apr 30, 2009
    Posts:
    438
    This should be pretty easy, you have your sprite on your bone, you can create the mesh one of several ways.

    Click on a sprite parented to a bone and press in the menu "Sprites And Bones/Skin2D" and it should automatically create a mesh with a SkinnedMeshRenderer component. You can use the Polygon Collider to make a better mesh for your sprite if you want more control over it. You can add deform points by clicking the "Create Control Points" button in the Skin2D component.

    See these previous posts on how to skin, create a polygon mesh, and weight paint it:

    http://forum.unity3d.com/threads/re...keleton-animation.219915/page-10#post-1795034

    http://forum.unity3d.com/threads/re...keleton-animation.219915/page-10#post-1805638
     
    esco1979 likes this.
  10. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    Had a quick question - do I need the ProjectSettings folder if downloading the ZIP of the project and importing into my project? I have been grabbing just the assets and leaving out the ProjectSettings when I copy into my project, in hopes of avoiding any possible problems with my current projects settings...

    Is there anything setup within unity specifically for Sprites and Bones that I should adjust in my own project?
     
  11. playemgames

    playemgames

    Joined:
    Apr 30, 2009
    Posts:
    438
    It should be fine without it as nothing relies on it :)
     
  12. esco1979

    esco1979

    Joined:
    Mar 18, 2014
    Posts:
    138
    PlayEmGames: Thanks for all of the info. :) With that, I got it to work and deform the mesh. However, I then realized that using a polygon collider or a sprite would not work to make the mesh I needed (shown below in the pic). So I downloaded blender, looked up a tutorial and in it I merged the vertices on 4 square planes together to make one big one. It seems to have come out exactly like the mesh I needed shown below.

    However, after loading the blender file into Unity, I attached the mesh in it as the mesh filter under the skin2d, but no matter what I do I can NOT get the sprite to show up with it. If I switch to another mesh I can get it to show up though. I have no idea why this is, but I attached my project with all of the necessary files. Can you please take a look at it? I spent over 6 hours today total messing with this trying all kinds of stuff.I have setup the control points and calculated the bone weights like normal, but no matter what I do it just won't work with the mesh.

    Pic of mesh needed (the at rest one on the left):

    Project file: https://mega.co.nz/#!1kFynKAK!3ex8czXOqkF2umxW-69wRuZkyI0aQWb1hDJDegnTk-c
     
    Last edited: Dec 19, 2014
  13. playemgames

    playemgames

    Joined:
    Apr 30, 2009
    Posts:
    438
    Did you UV the mesh vertices to the texture?
     
  14. Chistabo

    Chistabo

    Joined:
    Oct 24, 2014
    Posts:
    8
    Hi, all!

    Thanks to the authors / coders for this extension. ThumbsUp.
    Here is write-up of this thread in pdf. Meant as a manual / tutorial. Hopefully it will be updated.
    Play, please revise installation chapter and comment. Of course, I can send original Word2010 file.
    This version of pdf is not revised (that is, confirmed from coders) and therefore bears limited usability.
    Simon
     

    Attached Files:

    Last edited: Dec 22, 2014
    playemgames likes this.
  15. playemgames

    playemgames

    Joined:
    Apr 30, 2009
    Posts:
    438
    Great write up!
     
  16. Chistabo

    Chistabo

    Joined:
    Oct 24, 2014
    Posts:
    8
    Here is something weird going on when Skin2D is applied to sprite. With Camera selected in Hierarchy, Camera window gets corrupt.
     

    Attached Files:

  17. playemgames

    playemgames

    Joined:
    Apr 30, 2009
    Posts:
    438
    It's not corrupt you probably haven't got it as a child of a bone of a skeleton. It should automatically weight it to the bone, otherwise you have to manually weight paint it.
     
  18. Chistabo

    Chistabo

    Joined:
    Oct 24, 2014
    Posts:
    8
    Updated Manual Tutorial - now actually looks like tutorial.
    Using Play's latest gitHub version (unstable).
    Been playing with Skin2D function for 2 day now, and can't make it work, no matter what I try (everything).
    OK, read Q&A in the tutorial, and got the answer. Will update the manual in few days. It is not intuitive.

    Manual pdf is bigger than allowed 4MB for attached files. Please advise where to share it, since it will only get bigger with time.
    My suggestion:
    4shared website, and link to there somewhere in Play's gitHub ReadMe file. Jaa? Or Mega, GoogleDrive, DropBox... but not everyone has account, and 4shared is not bonded to account holders...
    Or I can e-mail to Play and he will include it in his gitHub DL zip file?
    Here is first update:
    [deleted]
    Second Update:
    http://www.4shared.com/office/x8IOTNWSba/SpritesAndBones_Tutorial_Manua.html

    Play, I would suggest:
    1) in SAB menu, put Skeleton at the top (1st place top to bottom).
    - put Bone below Skeleton
    - put Helper below Bone
    - put Create Mesh next, then the rest...
    This makes it easier and more intuitive for new users. Wait, there is more:
    2) Create Mesh (SAB menu) - please tell shortly why is it used (I do know how to)
    -- Is Generate Polygon button needed, or couldn't Create Mesh Button first create polygon (as per Vertex Dist. parameter), and then created auto-named mesh?
    3) Skin2D - can you make it to auto-name the created mesh?
    4) Selecting Ragdoll from SAB menu does nothing. Please explain shortly the procedure.
    5) Weight Painting - please explain shortly - why it is used, and how to use it?
    6) Sorting Layers and Material - please explain shortly - why and how?
    No need for long answers, except if you want something particular to be included in Manual.

    ThumbsUp!

    Simon
     
    Last edited: Dec 23, 2014
  19. Chistabo

    Chistabo

    Joined:
    Oct 24, 2014
    Posts:
    8
    Play, I forgot to ask you, if at all possible (and if it makes sense to others), please under Skin2D, set default Control Point size to something bigger, like 0,2, otherwise new users might get long nose, since Control Points with default size 0.01 are not visible.

    Best regards,

    Simon
     
  20. Chistabo

    Chistabo

    Joined:
    Oct 24, 2014
    Posts:
    8
  21. playemgames

    playemgames

    Joined:
    Apr 30, 2009
    Posts:
    438
    1) Not sure how the ordering works for the menu at all in Unity.

    2) Will do at my demo next month

    3) Tried to no avail to get that to auto name.

    4) Select skeleton, then go to Ragdoll and it should autocreate it.

    5) Used for skinning, explained in your own tutorial somewhere and in this thread numerous times.

    6) Again it's in this thread, and pretty self explanatory in the tool.

    I'll be demoing all the features at this meetup in LA next month:

    http://www.meetup.com/LAUnity3D/events/218990900/

    I made it so it fits for me and my sprite values, but if you change one, it changes them all since it's a static value. Thanks for all the work put into gather info in this thread, unfortunately with the holidays I'll be pretty busy and I'll be putting this demo together for next month so I can't do a lot of changes until then.
     
  22. Chistabo

    Chistabo

    Joined:
    Oct 24, 2014
    Posts:
    8
    Yea, I guess I should read it, at least once. LOL!

    Happy Holidays, and Happy New Year!

    Best wishes,

    Simon
     
  23. playemgames

    playemgames

    Joined:
    Apr 30, 2009
    Posts:
    438
    Happy New Year everyone! I've spent some time updating some things in my fork and I've finally included some preliminary mesh editing tools:

    upload_2015-1-10_16-6-14.png

    You can now create and edit custom polygons that can be saved as Mesh asset files. Select a sprite and go to the menu and click on Sprites And Bones/Create Mesh to open the window. When you click on the Create and Edit Polygon button it clears any existing meshes in memory and then creates a new point at the center of the screen. Hold Ctrl + click with the mouse to create points, hold Shift + click to add mid points, and Hold Alt + click to remove points. You can subdivide the current mesh using the levels 0-4, 0 being none, and 4 being the smoothest with most polys. Pressing Update Custom Mesh re-triangulates the current mesh, which should only be necessary if you can't see it. Save the mesh you created into the Meshes folder by pressing Save Custom Mesh.

    You can load a custom mesh to edit that you had previously created by dragging and dropping it into the Load Custom Mesh field and pressing the Load Custom Mesh button. You can edit the vertices by dragging them around with the mouse, and save the new mesh if you want, but adding and deleting points to the mesh will re-triangulate it which may not be the result you want.

    You can also combine another mesh to the current mesh you are editing, this is good for simple meshes only. Create a custom mesh, drag and drop the mesh you want to combine it with in the Combine Meshes field and press the Combine Meshes button. It will not save the mesh until you hit the Save Custom Mesh button so make sure you save it if you like the combination. Subdividing or adding points to a combined mesh doesn't always give the best results, as I haven't found a way to re-triangulate combined meshes properly yet.

    The other tool I have added is the Bake Poses Editor:

    upload_2015-1-10_16-52-31.png

    You can access the Baked Poses Editor by clicking on the menu Sprites And Bones/Bake Poses. In order to use this tool you need to have an animation created with a skeleton, select the root GameObject of the skeleton or skeletons you want to bake the poses for the Keyframe. Make sure the Animation window is open and the animation you want to bake poses is in is open and the keyframe you want to bake to is selected. Make sure the Record button is red in order for the Animation window to register the bake. Click on the Bake Poses button to bake the poses for all the skeletons that are enabled for the keyframe. Then the Clear Poses, Disable Skeletons IK, Enable Skeletons IK, and Apply Poses buttons will appear. Click on the Disable Skeletons IK button to disable the IK for that keyframe, then hit Apply Poses to bake the rotations to the keyframe. You can renable the Skeletons IK for the next frame by clicking on Enable Skeletons IK button. Clear the poses when you are done by pressing the Clear Poses button or hit Bake Poses again to start a new bake. You can do this for every keyframe you want to bake.

    It may take some tinkering to make sure all the rotations are keyframed, but this is the only method I have found that properly keyframes the bones rotations from the IK based poses. I've also tried to code this all in one button, however, the Animation window doesn't properly bake the rotations unless I have them restore the poses through the Apply Poses button after I have baked them prior using the Baked Poses button. If anyone can figure out a way to capture the rotations better with the IK method we use here I'd definitely like to hear it! I've tried to create animation clips by sampling the time and setting the curves manually, but I think it either ignores or is too fast for the IK calculations.

    Hope these tools help you out, I'll be demoing Unity Sprites and Bones here in Downtown LA, California in Little Tokyo at 7:30PM on Tuesday if you want to see how it is used properly. Enjoy! (And please let me know of any bugs!)

    https://github.com/playemgames/UnitySpritesAndBones/tree/unstable
     
    MD_Reptile likes this.
  24. playemgames

    playemgames

    Joined:
    Apr 30, 2009
    Posts:
    438
    MD_Reptile likes this.
  25. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    I'd be so grateful if sprites and bones could do this kind of IK limiting:

    http://kanako.dk/clients/AssetStore/2DIK/examples/

    Here you see the angle limited to only allow the elbows to go in one direction or the other even if the IK target (the mouse) is very far from the IK limbs.

    This is an example of 2D IK Solver - a $5 asset store package. If you try the "many arms" demo it shows you some are setup with their arms limited at different angles (some both bend the same direction, some bend in opposite directions)

    Is there any way to get the same kind of angle limiting within sprites and bones? Whenever I try out angle limits (for instance I assume min of 0 and max of 180 should get a similar effect) - and the IK target is like, 0.5 units out of reach from the end of the max length of the IK controlled limb (with 2 bones, upper and lower arm) it will start spazzing out on me. I think it has something to do with the way angle limits are calculated. Sure bums me out, and right now I try and work around the limitation by setting no angle limit, and only allowing the IK targets to move where they are still in range of the max angle of the IK limbs reach... hope that makes sense. Doing it that way tends to cause little errors where if I jump and flip my characters to the other direction whilst aiming around, eventually the limbs flip "inside out" or... backwards from the way an elbow should work :p

    I know I already bugged you a bit about this @playemgames but have a look at that demo scene and see if you can get the same effect from sprites and bones... maybe I am just doing something wrong with the limits and this is something that should already be possible?
     
  26. zee_ola05

    zee_ola05

    Joined:
    Feb 2, 2014
    Posts:
    166
    MD_Reptile likes this.
  27. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    I had seen that unite video a while back but had forgotten about it. Perhaps playemgames could find a way to apply this same technique to sprites and bones? I started digging into it a little and realized just how complex sprites and bones is, and how long it would require me to figure out how everything works before I would have a positive impact - and abruptly gave up to work on my game itself rather than the characters IK :p

    I really like sprites and bones so far for just using a single sprite broken into limbs, and then just animating in unity. If I can convince playemgames to tweak the IK limiting just a bit I feel like it would be perfect for my project. As is, it would work, but that IK limiting "spazzing" is the only thing that lets me down about it.
     
  28. Mateusak

    Mateusak

    Joined:
    Dec 10, 2014
    Posts:
    6
    Forgot.
     
  29. playemgames

    playemgames

    Joined:
    Apr 30, 2009
    Posts:
    438
    I did get this technique from that project, and I implemented it the best I could. And like yourself, I'm focused more on doing things that I need for my own projects than for everyone else's. The way the IK is solved is in the InverseKinematics.cs file, see it here:

    https://github.com/playemgames/Unit.../SpritesAndBones/Scripts/InverseKinematics.cs

    Maybe you can find a way to make it work in a way that I couldn't, but right now I have no need for angle limiting for IK, I have set up my rigs to have another IK chain with a helper to limit the main IK chains instead of using angle limiting.

    Hopefully you or someone else can find a solution from where I started, after all, I had never really worked on tools before this project, so maybe you can find it in yourself to be able to contribute for your own necessities as I have done and better the tool for all :)
     
  30. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    I might be able to come up with something. I will spend some more time tonight dissecting the IK script and toy with the angle limits somewhat. I'll tear apart that other project and maybe with the two sources I can figure something out that works for all of us.

    No promises haha. And again - I do appreciate the work you have already done here, and if I can come up with a solution that gets the same effect as those demo projects I'll be sure to post back and let you guys know.

    EDIT: Oh wow - that was easier than I thought it was gonna be haha.

    EXAMPLE PACKAGE: https://www.dropbox.com/s/gcltbjernoeom3e/Example_IK_SimpleCCD.unitypackage

    Ok all I did was open a new project up, get THIS EXAMPLE (thanks to @zee_ola05 ) from unity, import sprites and bones latest build, then started setting up my character from scratch (just to eliminate the possiblity I screwed anything up on it in my project).

    Once I had him set up, I went ahead and just used (in its exact form) the script from unity's example scene (the one called SimpleCCD.cs) and stuck it on the UPPER ARM of my character. Then I created two helper objects from S&B scripts, and named one R_HandEnd (required for SimpleCCD) and one called R_Target. Then I assigned the stuff in SimpleCCD to be 5 iterations, 1 damping, the target to be R_Target, the angle limits to be min of 40 and max of 150, and the transform of the angle limit to be his lower arm, plus the end transform to R_HandEnd. Then... BAM it just works. Cooperates no problem with sprites and bones as-is. So in reality I did... nothing haha. But it for some reason just works as expected thanks to the way it came setup in that example. Awesome! I think you should eliminate the IK that comes with sprites and bones, and just integrate SimpleCCD (which I see now was your basis for the IK limits anyway) and have that be attached through a button, and then ta-da it works like butter. No spazzing anymore! One satisfied developer here! Long live sprites and bones!
     
    Last edited: Jan 18, 2015
  31. playemgames

    playemgames

    Joined:
    Apr 30, 2009
    Posts:
    438
    Probably not going to eliminate the IK that comes with it because it handles things a bit differently. It calculates the rotations from the head to the tip of the bones and calculates the IK based on that and the IK chain length. Do you also have IK scripts on those bones as well? There are some things like root and skeleton transformation that are handled in IK that are not in SimpleCCD so you make find things like Flipping may break. Basically the SimpleCCD script uses transforms instead of a chainlength and bone rotations to handle the IK solving. What I might do though is write another script that can handle it the same way as SimpleCCD but also include the skeleton rotation and scale handling and make it a separate script as to not break anyone's current IK setups. It would work the same as the SimpleCCD and just ignore the chain length and handle rotations between the transforms.
     
  32. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    Flipping didn't break for me - but maybe because (if I am remembering correctly) I just flip the y of my characters parent gameobject rather than use the "flip" from sprites and bones - I think. I only use the SimpleCCD on the characters upper arms. In the example I had him setup with like a "root" sort of realistic skeleton, but on my actual game character I set it up differently... Heres an example screenshot:



    I wasn't aware that the included IK in sprites and bones handled things any differently as far as the IK chains and stuff goes - and in my setup I don't use a traditional bone structure either I use just bones on the arms, legs, and head, on two separate skeletons, and they are all disconnected from one another (no spine, no root bones or anything, bones for arms start at shoulder, bone for head at neck...) and perhaps this strange way of doing it is why I haven't run into any problems yet? I have a upper skeleton (arms and head) and a lower skeleton for the legs which are just animated. His body doesn't use a bone

    Anyway if you take the time to work something out to bring SimpleCCD into S&B I would be very happy! I am sure that it wouldn't work if you had many bones (or at least I don't think it would work) that go on a single appendage. In that case you might need a different solution for angle limits. But for a humanoid setup it seems to work well! Perhaps it could be included as a "simple IK" option to work as an alternative if you need a situation like mine.

    If I wasn't full steam in development of my game I might take some time to test out other setups and see what works and what doesn't, but for now I have to focus on other aspects of my game.
     
  33. playemgames

    playemgames

    Joined:
    Apr 30, 2009
    Posts:
    438
    Fixed some of the bugs with generating materials and added a useSharedMaterial bool variable for Skeleton so you can use the sharedMaterial instead of an instance. This should be useful for initial setups, or if you know you will be only using 1 instance only of that character.

    Also fixed the bugs with the mesh creation and editing your own polygon. This tool is still a bit buggy, but it is good for creating simple meshes, you can also combine 1 other mesh with a previously created mesh, but the results will vary so you have to experiment with it. I don't recommend combining a subdivided mesh with a new mesh as it seems to duplicate some vertices for some reason or another. To start from scratch just click on the Create and Edit Polygon button to clear the mesh.

    More info on how to use it in this previous post:
    http://forum.unity3d.com/threads/re...keleton-animation.219915/page-12#post-1916087

    https://github.com/playemgames/UnitySpritesAndBones/tree/unstable
     
  34. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    Anything on the road map for those IK changes? Or are you thinking you will leave that up to the user to decide whether to use the current IK limiting or integrate that other one the way I shared? Maybe you could include the other IK limiting script as an example or something.

    Either way thanks for the update!
     
  35. playemgames

    playemgames

    Joined:
    Apr 30, 2009
    Posts:
    438
    I'll get to it when I can, but can't give any definitive time frame at the moment :)
     
  36. playemgames

    playemgames

    Joined:
    Apr 30, 2009
    Posts:
    438
    I'll be at Mobile Camp LA in Hollywood doing a talk on Unity Sprites and Bones and game dev in Unity at 3:30. Registration is free, check out the details here:

    http://mobilecampla.com

    Unity Sprites and Bones is a Free Open Source 2D skeletal animation tool, I'll also be doing a short demo on the open source tool Unity PSD Importer as well. Here are some links to the tools:

    https://github.com/playemgames/UnityPsdImporter

    https://github.com/playemgames/UnitySpritesAndBones/tree/unstable

    Looking forward to seeing you there!
     
  37. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    Is there any way to assign poses back to a skeleton besides it being the base pose? I mean I don't totally understand the purpose of poses can I set one pose and then create an animation and move the time down and assign another pose to have the animator interpolate between them? If not what are you supposed to use poses for, besides putting skeletons in the base pose?
     
  38. playemgames

    playemgames

    Joined:
    Apr 30, 2009
    Posts:
    438
    Sure you can do it in code:

    skeleton.RestorePose(savedPose);

    You can do as you mentioned, I have that in the baking poses tool as well. You can also use poses to initialize the rotations and positions of all the objects in the skeleton before playing an animation so it will animation properly between different animations. You can use poses for animations that use the same pose as another animation. I use this a lot actually, the Bake Poses tool can copy and assign poses from one animation to another pretty easily. This saves a lot of time since you don't actually have to save out a pose and then assign it as a base pose and restore it manually. It all happens under the hood and you can basically copy and paste poses between animations. In order for some of the keyframes to be set sometimes you need to move around the objects to different positions/rotations on purpose so it recognizes that the object has changed and sets the keyframes.
     
  39. Rustamovich

    Rustamovich

    Joined:
    Sep 5, 2014
    Posts:
    36
    Hello everybody!
    I am expiriencing huge drop of performance by using SpritesAndBones, I test in on my Android mobile phone by using Unity Distant Profiler

    So on Idle mode, when my player doing nothing (just breathing) we have 10.0ms CPU time used by SkeletonLateUpdate, so my FPS dramatically falls, when in Scene we have another character FPS is around 15 (!!!!!!!)
    If I have 4 of them(characters) I've got huge drop of performance in Editor too!!!!!

    My android device tech specs is:
    Android 4.4
    512 RAM
    4-core MediaTek MT6582, 1300 Mhz CPU

    This is how my skeleton is look like:
    http://s16.postimg.org/pgjihdwxh/image.png
    Nothing special. some IK helpers and that all
    Have someone ideas how to cure it? Have somebody expirienced the same trouble?

    Thanks in Advance
     
  40. playemgames

    playemgames

    Joined:
    Apr 30, 2009
    Posts:
    438
    Are you using the latest version of my fork? How many vertices are in the SkinnedMeshRenderer? Your rig looks fine otherwise, if the IK is really slow on the device you may need to bake the animation by using the Bake Poses tool to bake all the keyframes in and disable the IK.
     
  41. Rustamovich

    Rustamovich

    Joined:
    Sep 5, 2014
    Posts:
    36
    Hi,
    Yes, I am using the latest version of your fork, I dont use morphing at all, only IK. Can you explain me how work process with baking poses look like?
    I see this that way: For example i have 3 key poses, so i call them programmatically at 1,30, and 60 frame of my animation, and somehow unity engine do ease transition between two keyframes.
    Am I right?
     
  42. KurtGokhan

    KurtGokhan

    Joined:
    Jan 16, 2013
    Posts:
    37
    Hi, this is a great package and thank you for sharing it. I have some questions.
    I have parts of a human body as separate sprites. How can I create a skinned mesh with them? We can create mesh from sprite with the scripts but do I have to create skinned mesh with external tools? At first, I thought the scripts would also generate the skinned mesh. But weight painting requires a skinned mesh renderer which requires a skinned mesh.
    I basically want to do something like you did in this:
     
  43. KurtGokhan

    KurtGokhan

    Joined:
    Jan 16, 2013
    Posts:
    37
    Okay, I solved my problem. My problem was that when I added a Skin2d component to a sprite it would create a rectangular mesh from the sprite. To change the mesh, I was trying to change mesh in SkinnedMeshRenderer. Instead I should have changed mesh in MeshFilter.
     
  44. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    FYI I made a little script to assign a pose to a skeleton in the editor... I couldn't find the option in sprites and bones if it already exist, so I made this:

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4. using UnityEditor;
    5.  
    6. public class SetSpritesBonesPose : EditorWindow
    7. {
    8.     Skeleton skeleton;
    9.     Pose pose;
    10.  
    11.     [MenuItem("Ninjetic Tools/Sprites And Bones/Set Character To Pose")]
    12.     private static void SetPose()
    13.     {
    14.         // call the editor window to create a new terrain
    15.         EditorWindow.GetWindow(typeof(SetSpritesBonesPose));
    16.     }
    17.  
    18.     public void OnGUI()
    19.     {
    20.         GUILayout.Label ("Skeleton To Set Pose", EditorStyles.boldLabel);
    21.         skeleton = (Skeleton)EditorGUILayout.ObjectField (skeleton, typeof (Skeleton), true);
    22.  
    23.         GUILayout.Label ("Pose To Set", EditorStyles.boldLabel);
    24.         pose = (Pose)EditorGUILayout.ObjectField ("Pose", pose, typeof(Pose), false);
    25.  
    26.         if(GUILayout.Button("Set Pose Now"))
    27.         {
    28.             if(skeleton != null && pose != null)
    29.                 skeleton.RestorePose(pose);
    30.         }
    31.     }
    32. }
    33.  
     
  45. KurtGokhan

    KurtGokhan

    Joined:
    Jan 16, 2013
    Posts:
    37
    Hi, I am having problem with skinned meshes. For example I make upper leg a skinned mesh and save it as a prefab. Next time I revert to that prefab and try to paint weights, I get errors (Weight painting window doesn't even load). Errors are caused because it cannot find bones. I can understand that when it is saved as prefab, it is seperated from its parents so bone connections may get lost. How can I overcome it?
    Also when saving prefabs, sometimes material connections get lost and this breaks everything.
    I think when you designed this system you planned of all this. But I can't figure it out myself. Can you show us your workflow in creating a character?
     
  46. playemgames

    playemgames

    Joined:
    Apr 30, 2009
    Posts:
    438
  47. playemgames

    playemgames

    Joined:
    Apr 30, 2009
    Posts:
    438
    Please post your project, I am trying to hunt down this bug since it came up in one of my demos. Make sure you have materials saved out before saving as a prefab otherwise it can break the prefabs.

    You can check out how I create a skeleton and everything here:

     
  48. playemgames

    playemgames

    Joined:
    Apr 30, 2009
    Posts:
    438
    Try looking at this post for the bake poses editor:

    http://forum.unity3d.com/threads/re...keleton-animation.219915/page-12#post-1916087
     
  49. KurtGokhan

    KurtGokhan

    Joined:
    Jan 16, 2013
    Posts:
    37
    Okay, I will post the package as soon as I can. Also, do you accept code contributions? I noticed angle limits of IK wasn't working correctly and fixed it.
     
    MD_Reptile likes this.
  50. playemgames

    playemgames

    Joined:
    Apr 30, 2009
    Posts:
    438
    Sure you can post it up on github and do a pull request.