Search Unity

Puppet2D - An advanced skeletal animation tool

Discussion in 'Assets and Asset Store' started by jamieniman, Dec 31, 2013.

  1. maltadirk

    maltadirk

    Joined:
    Mar 12, 2014
    Posts:
    43
    @jamieniman Hey!
    I'm currently testing out both Uni2D and Puppet2D. Have to say Puppet2D has more features with regards character rig but I'm running into some issues hope you can help.
    This one particularly annoying me.


    The above images shows I have a sprite sheet set at Multiple with all components named.


    The above image shows how I converted the sprites into meshes using the "Convert Sprite To Mesh" in the Skinning Panel.


    The above image shows both bones and mesh to be combines together. Then I click on "Bind Smooth Skin" making sure I have "Num Skin Bones" set to 2


    Finally the above image represents the problem. For some reason the mesh has been converted to the sprite atlas rather then using the specific single sprite.

    Thanks
     
  2. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    Have you updated to the latest version of puppet2d? That looks like an old bug?
     
    maltadirk likes this.
  3. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    It almost looks like its pre-rendered!
    The way to achieve that is by a mixture of FFDs, and texture material swapping
     
  4. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    You should have a unique global_CTRL for each character. Keep a separate scene and prefab for them. If you rename the global_CTRL, make sure you rename it back if your making changes to the rig.

    If you're animating a cut scene its a good idea to put all your characters (global_CTRLs) under one gameObject, remove the animators from them, and have one animator on that gameObject. That way you can animate them at the same time.

    Try to keep your parts organised under the global_CTRL - essentially you should have 3 sections: bones, controls, and meshes). It mioght be useful to add 3 gameobjects and under your global_CTRL as labels for each of the sections.
     
    EliRiverback and maltadirk like this.
  5. maltadirk

    maltadirk

    Joined:
    Mar 12, 2014
    Posts:
    43
    You're very right @jamieniman updated and works like a charm! :)
     
  6. JasonAppxplore

    JasonAppxplore

    Joined:
    Jan 14, 2015
    Posts:
    18
    Not sure if this bug was reported before, but if I undo right after I click on Create FFD Tool, I get forever stuck in FFD mode. Happens in 4.6.
     
  7. EliRiverback

    EliRiverback

    Joined:
    Feb 7, 2013
    Posts:
    2
    What Jason just described is a huge problem with me too and I guess you just need to get used to it right now and try to avoid it.

    My question considers the performance, which seems to be amazingly improved in the newest version. Is this right or is it just us? Now we can spam our animated game objects with no worries when before we could only run few of them. The biggest fps drop was on windows phone, but also our computers are using a lot of less power than before. Usually our laptops were hot as hell, but now they have been cool all day. We also updated the Unity, but I don't think that's the case.

    There was "-Unity 5 skinning bug fix" in newest release notes (EDIT: Which seems to be for 2.1. Is there release notes for 2.2?), could someone explain a little cause we have been using a lot of hours for optimizing. (and making our animations more simple and a lot more crappier).

    EDIT: Our skinning meshes were the most expensive part, so what I described makes sense.
     
    Last edited: Jun 2, 2015
  8. Manny Calavera

    Manny Calavera

    Joined:
    Oct 19, 2011
    Posts:
    205
    Hi,

    I'm noticing a 200B allocation per frame. Would it be possible to preallocate and reuse these objects instead?

    Puppet-Profiler.PNG

    Unity 5.0.2f1, Puppet2D 2.2
     
  9. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    Thanks for the bug report - ill add it to my trello
     
    EliRiverback likes this.
  10. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
     
  11. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    I haven't done anything in part
    I haven't done anything in optimising specifically. How old was your previous version - as there was a bug I knew of ages ago where the memory wasn't being cleared. But that was in v1 so it may not be that.

    I've updated the website with the latest release notes for v2.2:

    They are:

    - Multiple Bone IK
    - New Smooth Weights (old one now uses CTRL & SHIFT)
    - Square Mesh Triangulation, with 5 subdivision levels
    - Auto creation of global_CTRL and parenting
    - Mesh Centric UV Offsetting
    - Multi-object sorting layer editing
     
    EliRiverback likes this.
  12. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    Could elaborate a bit?
    (The script which runs all the scripts is Puppet2D_GlobalControl.cs - it has a few public lists for all the control types, which it iterates through and fires off their functions)
     
  13. Manny Calavera

    Manny Calavera

    Joined:
    Oct 19, 2011
    Posts:
    205
    Precisely! Iterating through lists using foreach will create a new object (Enumerator) every time and immediately dispose of it. Doing this every frame will keep leaking these objects and eventually lead to a GC pass.
    Since the number of bones doesn't change in run time, arrays would be a better alternative.
    You could still use the Lists during editing but in runtime, convert the lists to array and iterate through them using 'for' instead of 'foreach'.

    Independent of the issue above, another thing I noticed are multiple references to transform. Every time you refer to this.transform Unity will do this.GetComponent<Transform>() under the hood. This costs CPU that could be avoided if you cache the Transform. For instance, in Awake(), store this.GetComponent<Transform>() in a private field and use that instead of this.transform.

    These are all common pitfalls of managed code and Unity. All easy to fix. Send me a PM if you need examples since I don't want to post part of your code here in the public forum.

    Cheers! Keep it up, Puppet2D is a great tool.
     
    funshark likes this.
  14. Freeubi

    Freeubi

    Joined:
    May 30, 2014
    Posts:
    21
    [if i say something stupid, then ignore me, its late here]

    I'm curious, if we have made animations with an older version of Puppet2D (like v1.6 or 2.1) and update the plugin to the newest version, can we notice some benefits?
    Like more performance, efficient memory use etc
     
  15. TommySKD

    TommySKD

    Joined:
    Jul 23, 2014
    Posts:
    25
    Hello, Puppet2D is a very nice tool, but I have a few questions:

    - Is it possible to rename "Global_CTRL" to something else and still have new bones/controls being created parented to it? At the moment if you do that it always creates a new "Global_CTRL" and you have to manually drop the created bones/controls to your renamed Global_CTRL every time, thats a bit annoying. Maybe add a Global_CTRL selector or something.

    - Is it possible to somehow rotate an entire IK with a simple rotation parameter? I tried doing that by adding an Orient Control at the base of the IK but it doesn't have any effect, I suppose that is because the IK Control is calculated after the Orient Control and thus completely overrides it, being able to control the order of calculation of the controls would be great. Or just give the IK control a rotation offset parameter. (for instance I would use it to dynamically and easily rotate an entire character arm by script during his attack animation so it faces the cursor)

    - I think the Puppet2D window could use a more compact aspect, for example if you scale it down enough the "Skeleton", "Rigging"... buttons would be replaced by small icons and the puppet guy picture would no longer appear, etc..

    Anyways keep up the great work!
     
    Last edited: Jun 6, 2015
  16. ricarditoceroncito

    ricarditoceroncito

    Joined:
    Jun 6, 2015
    Posts:
    1
    Im working on a 2d platformer... I already have my character running and crouching and jumping and everything else... now is the part where I have to code the movement and animations... I made all my animations facing right... how do you make the character flip 180 with all his animations so everything works hshen its facing left
     
  17. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    There was a bug in a much older version where there was a memory leak - I can't remember how long ago that was. I would recommend getting the latest versions as it has more features and bug fixes. (Make sure you back up before updating though, just in case)
     
  18. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    I see the issue, currently I recommend temporally naming the working Global_CTRL back whilst you are editing the rig
    You should parent the handIK_CTRL_GRP to the orient_CTRL and then perhaps remove the orient_CTRL script as it isnt needed.
    thanks for the feedback!
     
  19. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    There is a flip checkbox on the global_CTRL (make sure everything is parented to the global_CTRL by the way)
     
  20. Caffeen

    Caffeen

    Joined:
    Dec 25, 2013
    Posts:
    34
    Any idea when 5.1 compatibility might happen? Puppet2D is throwing tons of console errors now, but I hope it's not too involved of a fix. :)
     
  21. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    For anyone updating to Unity5.1, open the Puppet2D_BakeAnimation.cs search for #if UNITY_5_0 and replace with #if UNITY_5_1

    I'll try update the asset with a fix soon
     
  22. Caffeen

    Caffeen

    Joined:
    Dec 25, 2013
    Posts:
    34
    Awesome, thanks for the lightning-fast response. I'm glad it was such an easy fix! Puppet2D was one of my first Asset Store purchases over a year ago and is still one of my favorites!
     
  23. jameskyle

    jameskyle

    Joined:
    May 7, 2013
    Posts:
    37
    Even with this fix I'm still getting one error:
    Assets/Puppet2D/Scripts/Puppet2D_BakeAnimation.cs(442,7): error CS1028: Unexpected processor directive (no #if for this #endif)
    Does anyone know what this means or have a way to fix it?

    Update: Commenting out the last line - #endif - got rid of the error but I've yet to test whether it actually runs.
     
    Last edited: Jun 12, 2015
  24. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    Did you keep the #if at the beginning of #if UNITY_5_1 (it wont work if you remove it )?
     
  25. jameskyle

    jameskyle

    Joined:
    May 7, 2013
    Posts:
    37
    I'm not sure as I no longer have the file that caused the error. I deleted and re-imported Puppet2D from the asset store then did a find/replace in MonoDedvelop to change the #if UNITY_5_0 to #if UNITY_5_1. I used the find/replace the first time and it didn't work too, so I must have done something wrong but it's all working now and my game is on GameJolt in HTML5. No idea how I mucked it up the first time.
     
  26. Bromm

    Bromm

    Joined:
    Nov 18, 2014
    Posts:
    18
    Hi. Have a problem with crashing unity (5.1.0f3) when i press "Bake Animation" button.
    P.S. Its not a console error. Its a crash. As i understand, I'm the only one who has such problem, so I'll try to find out the reason and put a feedback here.

    The problem was in P2D baking all animations instead of selected one. unity was just overworked. it took 10 hours to handle with all anims
     
    Last edited: Sep 3, 2015
  27. HarisKap

    HarisKap

    Joined:
    Dec 10, 2012
    Posts:
    20
    Hello,

    I am making a 2d beat em up game where the characters can move on x and y axis.

    I am doing :

    foreach (SpriteRenderersRendererinspriteList){
    sRenderer.sortingOrder += (int)(characterSortingOrder + valueToAdd);
    }

    valueToAdd is 1000 but the weird thing is that every few seconds the sRenderer.sortingOrder swaps from negative number to positive. why is that happening? from -3000 goes to 3000 and mess up my sorting order.

    Has to do with the way that animations are build? any ideas hoot fix that?

    thank you
     

    Attached Files:

  28. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    I can't immedietly see what could be causing the issue - puppet2d doesn't change the sorting order on sprites. The screenshot you posted includes the puppet2d controls. I'd recommend turning these off in the global_CTRL and not including any disabled spriteRenderers in your code
     
    HarisKap likes this.
  29. DATuan91

    DATuan91

    Joined:
    Aug 2, 2013
    Posts:
    9
    Hello

    I am making 2D runner game using Puppet2D. It's a great and flexible tool.

    I have face some problems when using this related to Android platform:

    After finishing rigging and skinning character, I switch build target (in Player Settings of Unity) to Android (previously is PC) and suddenly some sprites are wrongly displayed. Only sprites which are already "Convert Sprite To Mesh" have wrong UV (texture is offset to left and bottom direction), all other sprites are OK. I switch build target back to PC and every sprites is OK again.

    Some Information:
    - I'm using Puppet2d v2.2
    - Unity3D 4.6.6p2. Project and assets is newly created in same version of Unity
    - I set Texture override in Android to "Don't overried"
    - I try changing format of Sprite to Compressed, True Color, 16 bit, but no luck

    Do you have any way to fixing that?

    Thank in advance
     
    Last edited: Jun 18, 2015
  30. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    Make sure your sprite textures are square, and are power of 2. Unclick mipmapping of the textures as well. Let me know if any of that helps?
     
  31. NAiLz

    NAiLz

    Joined:
    Apr 17, 2013
    Posts:
    88
    Unity Puppet2D Error Messages.png Hey jamieniman. Love this asset. I was using it to build my characters in a game I was working on in Unity 4. Now that I've upgraded to 5, I'm getting a TON of console errors. Here's a screenshot. I tried the fix you mentioned above editing #if Unity_5_0 to #if Unity_5_1 but it didn't fix anything. Any ideas why this is happening? Is it conflicting with another asset?
     
  32. DATuan91

    DATuan91

    Joined:
    Aug 2, 2013
    Posts:
    9
    Thank you for your support
    Make sprite square and has size power of 2 solve problems.

    But I wonder why size of sprite causing problems?
     
  33. BTStone

    BTStone

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

    after some playing with the tool, looking at the videos and reading the docs I really like the tool, but there are some points I find tiresome/would like to request.

    1) If I have a sprite and use basic FFD on it and finishing it a Mesh and Material is generated.
    Is it possible to save these two files not in the Puppet2D Folder but in a seperate one for example in the Folder of the raw sprite-file?

    2) When I use the Spline Tool on a sprite and finish the spline and then use FFD on the sprite in order to animate the bones I have to use "Bind Smooth Skin" - in order to do that I have to select each bone and each SpriteName_Ctrl Object and then hit the button. With lots of bones and SpriteName_Ctrl Objects the selection-process is quite tiresome.

    [PRO Tipp for whoever has issues with that, too: write "SpriteRenderer" in the Hierarchy-Searchbar and it will give you all the needed bones and SpriteName_Ctrl Objects, since these have the SpriteRenderer-Component attached]

    But even with this pseudo-workaround - would be great if there was a more userfriendly-way to do that.


    Edit:

    and 4) When everything is setup correctly, Selection of the Object in Scene-View is kind of difficult. Clicking on the Object will select the Mesh but not the Global_CTRL Object. Clicking the desired object everytime in the Hierarchy-View in order to select it to move it around is...annoying :D

    Any workaround for this?
     
    Last edited: Jun 19, 2015
  34. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    I'll give this some thought, and add it to the feature list

    You don't have to select the FFD controls - instead try selecting the FFD mesh and the bones and click "Bind Smooth Skin". That also works! I added this after I made the tutorial ;-)

    If you are making a prefab out of your global_CTRL, make sure you break the prefab instance when you wish to animate - this will allow you to select things easily in the scene view as opposed to the hierachy. Also make sure you put the characters sorting layer on a locked character sorting layer
     
  35. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    Please try deleting the triangulation folder and reimporting Puppet2d.

    Otherwise there is likely another asset that has the same triangulation library. You may get away with deleting the triangulation folder altogether and it will still work

    Let me know how you get on
     
  36. NAiLz

    NAiLz

    Joined:
    Apr 17, 2013
    Posts:
    88
    Thanks jamieniman. I'll try this as soon as I get home from work. Appreciate the fast response.
     
  37. Manny Calavera

    Manny Calavera

    Joined:
    Oct 19, 2011
    Posts:
    205
    Hi @jamieniman,

    Have you had the chance to look at my previous posts? I've upgraded to 2.3 and still see about 600 bytes allocated per frame from GlobalControl.

    Puppet-Profiler-02.png
    As for HiddenBone, the memory allocation happens when resetting sortingLayerName. However the bones are normally only marked visible in the editor so this is not as important as the GlobalControl.

    Please, can you get this down to zero bytes?
     
  38. NAiLz

    NAiLz

    Joined:
    Apr 17, 2013
    Posts:
    88

    UPDATE:
    I found the duplicate triangulation folder. I'm using Ferr 2D and it shares the same library. I just deleted one and everything appears to be working fine! Thanks!
     
  39. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Ah, yes, that works indeed, great! Thanks! :)

    Nah, that wasn't the issue here. When the Sorting Layer was locked and I clicked on the GameObject in the Scene View it didn't select the global_CTRL Object at all, when unlocking the sorting Layer it only selected the Mesh when I clicked on it in the Scene View. But when I made a Prefab out of it it selects indeed the whole global_CTRL (which I renamed btw.)


    Edit:

    I second @Manny Calavera post! Especially in a scene with lots of animated sprites this could be quite a hassle.
     
  40. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Another thing:

    DrawCalls.jpg

    If I get the plugin right, everytime I FFD a sprite a (skinned) mesh is generated which will produce one DrawCall (or SetPass Call) .
    In the image here there are three seperate Puppet2D-Meshes, which were deformed. Now they give me 3 DrawCalls.

    If I would duplicate on of them, I still will get 3 DrawCalls. But if I add a completely new Sprite and FFD it I'll get 4.

    Is there a way within Puppet2D to batch the materials of the meshes, so for example with this image:
    instead of 3 DrawCalls I'll get one since the two Bushes and the DonutFlowerGroup share all the same material?
     
  41. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    Try the combine meshes tickbox on the global_CTRL. It will make a single mesh out of all the children assuming they can share the same material.

    It may not always work in every situation however, and I would recommend adapting this script to combine all you're similar meshes:
    http://wiki.unity3d.com/index.php?title=SkinnedMeshCombiner
     
  42. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    Apologies, for not responding earlier - could you email with more info about this (puppet2d@gmail.com) - hopefully I could get this into the next update
     
  43. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    I got another issue:

    The default-shader the materials for the objects is Unlit/Transparent. Applying other shaders (especially more performant shaders) results in the meshes not being displayed anymore. Most of the shaders I tried didn't work.

    ShaderIssue.jpg

    Why is that? Would be great to be able to use other shaders, because sometimes we'd like to apply slightly different colors to the objects or/and use lights in the scene.
     
  44. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    What shaders are you trying? - I just tried every shader that comes free with Unity (and has a _MainTex) and they all work fine...

    Are you using the latest version of puppet2d? (v2.3)
     
  45. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Yes, using the latest Puppet2D version.

    Here are the shaders I tried:

    - Standard/Transparent (works, but this isn't going to work, cause of the mesh-edges)
    - Sprites/Default
    - Sprites/Diffuse
    - All UI Shaders
    - Puppet2D Shaders (vertColor results in a black shape)
    - Unlit/Transparent Colored

    The shaders I would like to use is from the Ferr2D and 2DToolkit Plugins, especially the BlendVertexColor-Shader from 2DToolkit:

    2DToolkitShaders.jpg
     
  46. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    Oh I see now - you're using vertex colour shaders on it - for that you'll be wanting to assign some vertex colours to the mesh. (Using VPaint or something)

    May I ask what you're trying to achieve with you're shader - maybe I can point you in the right direction.
     
  47. Nyxo

    Nyxo

    Joined:
    Mar 12, 2013
    Posts:
    23
    Hey jamieniman,

    I took a look thru the source and couldn't find anything obvious to do what I'm trying to do -- hopefully I've just overlooked something obvious, and you can point it out to me.

    What I've got is a Transform whose position/etc is affected by one of the IKHandles. Through a variety of other calculations, I've determined that I need to move my Transform a specific amount, but to maintain the IK chain it's a part of, my understanding is that the only thing I should move is the IKHandle itself-- that said, is there a way to easily calculate how much I need to move the IKHandle in order to achieve the desired offset of the other Transform? I obviously can't just move the IK handle by my calculated amount because rotations/angles in the IK chain will put my Transform in slightly incorrect positions in many cases.
     
  48. alexander-mofr

    alexander-mofr

    Joined:
    May 25, 2015
    Posts:
    5
    Last edited: Jun 24, 2015
  49. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Yes. Applying vertex colours to the mesh - how exactly would/should I do that?

    What we're trying to achieve:

    1) Performance. Specific shaders give us better performance on the PS Vita (our target platform)
    2) We'd like to change the color of some sprites/meshes in Edit-Time.

    On the right you see a Sprite where we can tweak the Colors as we like, and on the left it's the same "Sprite" but just a SkinnedMesh, made with Puppet2D (FFD), where we can't change the colors:

    SpriteColor.jpg

    3) We'd like to use lights in the scene with the meshes :D


    Another thing I notices: there is some flickering around the edges with some of the meshes I generate. I made a gif (hopefully you can see what I mean, gif is 20MB big!):

    http://gph.is/1CsRNFz

    The gif shows the raw sprite on the left and the generated FFD-Mesh on the right. When the camera moves you'll see a flickering of some pixels, happening on the edges of the mesh.

    With Sprites this happens when I scale a sprite smaller, which is normal, since information is "lost" and the GPU has to "guess" what should be displayed at that certain frame.
    But why does it happen with the Meshes, where the scale is not changed?

    Thanks! Appreciate your support!
     
  50. timothyallan

    timothyallan

    Joined:
    May 22, 2013
    Posts:
    72
    When you say it may not always work... would this be an example of it not working? Combine Mesh Off / On: Screen Shot 2015-06-26 at 12.35.29 AM.png Screen Shot 2015-06-26 at 12.35.37 AM.png