Search Unity

Puppet2D - An advanced skeletal animation tool

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

  1. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    did you parent the bones to the global_ctrl?
     
  2. coreymill

    coreymill

    Joined:
    Jun 8, 2014
    Posts:
    3
    I did not ... stupid mistake.

    Sorry for the trouble. I really appreciate the timely response!
     
  3. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    No worries, glad I could help :)
     
  4. coreymill

    coreymill

    Joined:
    Jun 8, 2014
    Posts:
    3
    Question #2

    I was initially using -transform.localScale.x to flip the character, but that messed up the animations, so I switched over to using the flip that is built in to puppet2d and that flips the animations correctly.

    However, the ability to light the character breaks on the meshes. I have some objects which are still sprites and they are lit normally whether flipped or not. However, the ones which I converted to meshes only light correctly when they are not flipped. I have them all set up to use the Sprites/Diffuse shader.

    Meshes are lit correctly when not flipped ... dark and in shadow when flipped.

    Any help resolving this issue would be greatly appreciated.

    Thanks.
     
  5. SeTHBeaRzz

    SeTHBeaRzz

    Joined:
    Jan 8, 2014
    Posts:
    35
    Does Puppet2D currently support Avatar Mask?
    If so how can I achieve this. I followed the Mecaim Tutorial By Unity on youtube but to no affect.

    The Rig that I'm currently using is a humanoid, but when I try to de-select the Avatar Mask parts, it takes no affect on the Puppet2D rig in Mecanim.
     
  6. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    I haven't researched this fully, but I don't think there is a quick way to make Unity Avatars on things which aren't imported like an fbx rig.

    There is a thread about making a custom avatar here:

    http://answers.unity3d.com/question...vatarbuilderbuildhumanavatar.html?sort=oldest

    How have you made it a humanoid rig?
     
  7. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987

    I think I know whats causing it, and have a possible fix, although it is a trade of with another bug (please email ur invoice # to puppet2d@gmail.com so I can send it to u)

    Heres a long explanation of whats going on :

    - flipping code needs to be in the global_Ctrl script so that its executed after the control code.
    - Originally I used to scale -1 in the X.
    - But there is a problem when you add a rigid body 2D to anything that has parents with rotations, where scaling in the x breaks it.
    - to get around this issue I rotate it 180º in the Y and scale it -1 in the Z. This fixes the rigid body issue
    - Unfortunately it reverses the normals used by a lit shader.
     
    Last edited: Jun 11, 2014
  8. SeTHBeaRzz

    SeTHBeaRzz

    Joined:
    Jan 8, 2014
    Posts:
    35
    Thanks for the respond, I'll look into it.

    I do however, have encountered another problem regarding flipping the rig.
    I'm utilising Puppet2D_GlobalControl.flip to flip the rig.
    It works fine as it flips the rig on its pivot point, however I can't seem to change the pivot point.
    Is there a way to change the pivot point position?
     
  9. DeepSeaDigital

    DeepSeaDigital

    Joined:
    Nov 9, 2013
    Posts:
    14
    Hey I have a quick question, Is there a way to hide the bones? I have tried to do it the way that you did in the tutorial with the layers but it didn't work and I have tried to hide the mesh renderer of the bones but It only hides the bones and not the joints. Is there a work around ? thanks in advance
     
  10. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    You need to unparent everything from the global_CTRL, then move the global_CTRL, and then reparent them.
     
    sam_nau likes this.
  11. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    Did you parent the bones to the global_CTRL? (The bone visibility toggle works only on the children of the global_CTRL )
     
  12. DeepSeaDigital

    DeepSeaDigital

    Joined:
    Nov 9, 2013
    Posts:
    14
    thanks that worked, I had it all in a empty gameobject. I appreciate the help
     
  13. SeTHBeaRzz

    SeTHBeaRzz

    Joined:
    Jan 8, 2014
    Posts:
    35
    Thanks for the advice, solved the problem. XD
     
  14. bayunugroho

    bayunugroho

    Joined:
    Jun 18, 2014
    Posts:
    1
    Hi, just bought your plugin, pretty like it :D
    Instead swap of the sprite can we swap mesh? (e.g I want to change hand with) Everytime I swap the mesh, it always invisible.
     
  15. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    At the moment you can only swap sprites, and not meshes.
    A big reason for this is that the meshes have their own specific skinning information and vertices.

    The way to do it currently is to skin all the meshes you want to use to the bones and animate the activity of the "Skinned Mesh Renderer" (so for example lets say you have two hands - handOpen_GEO and handFist_GEO, to swap them: keyframe the Skinned Mesh Renderer of handOpen_GEO off and handFist_GEO on)
     
  16. kautsar211086

    kautsar211086

    Joined:
    Jan 31, 2013
    Posts:
    3
    Hello jamieniman, we've some issues

    we need to change this dude's body to another type of body. What we need to do is swap the body mesh, like bayunugroho said before. we've do what you said (swap in keyframe)
    , but in our case we have 50++ whole body parts (create character), and need to use just 1 rig to make more effective (we're just a small team). Is there any methods that we can use?

    in pic,
    1. we want to change the sprites (body&leg)
    2. change the mesh
    3. missing body

    thanks, good work :)
     

    Attached Files:

    • 12.png
      12.png
      File size:
      284.7 KB
      Views:
      1,228
    Last edited: Jun 19, 2014
  17. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    Having a look at the style of your character, I would suggest not using skinned meshes, and parent the sprites to the bones (splitting him up as pieces at the joints) You can often get away with a lot without needing to skin the mesh. As long as the colors are similar around the pivots. That way you can use the Unity sprite switching.

    If you still want to use skinning (for more bendy body parts) You don't need a separate rig for each body part. You will have one rig which has one set of bones and controls, just you will need to bind all the body part meshes to the same bones.
     
  18. jamez

    jamez

    Joined:
    Jun 17, 2014
    Posts:
    14
    Just wanted to say that we've been experimenting with Puppet2d, and we're enjoying it. The mesh skinning in particular seems like the best work flow for those features currently available on Unity. We're planning on using it for a point and click adventure game.

    Our most anticipated features are:
    1. Adjusting bones after skinning - Often you aren't quite sure exactly where the joint should be, being able to adjust this would speed up the iterative process immensely. (Being able to leave control points attached would be even better)
    2. Spline tool - Right now animating with orient controls gets the job done, but is slow to animate long chains.

    Of course stability is always the most important than feature to us. Right now if you do everything in the correct order it works well, but we've had a few cases during the rigging process where things went haywire (especially during our first few tries where we were undoing and deleting a lot, and didn't understand the correct hierarchy).

    Thanks for the tool! I hope you keep working on it. I think it could become the de facto Unity 2d animation tool. Even as it is right now, I think it's good enough to use in a full game.
     
  19. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    Glad you're enjoying it,

    There is a way to adjust the bones after skinning,whilst keeping the skin weights. I haven't tested it much - but try it out and let me know if it works for you:

    1. Select the skinned mesh and click edit skin weights
    2. Select the skinned mesh again and click "bind smooth skin", this will ask you if you want to detach the skin, say yes.
    3. Move the bones.
    4. Select the bones and mesh in the same order and click "bind smooth skin"
    5. Click "Edit Skin weights" to come out of skin weights editing

    Of course you can skip stages 1 & 5 if you haven't editted the skin weights from their default.

    I'm def always working to improve Puppet2d, and spline tool is soon on the agenda

    Sneak Preview

     
  20. kautsar211086

    kautsar211086

    Joined:
    Jan 31, 2013
    Posts:
    3
    okay thanks Jamie! I try to experimenting first, maybe we can find out which method that will work.
     
  21. jamez

    jamez

    Joined:
    Jun 17, 2014
    Posts:
    14
    Thanks, that makes it much easier if you have done time consuming skin weight editing, so you don't have to throw it all out.

    However, the workflow for unbinding/rebinding the smooth skin is still not very good, and prone to mistakes (the question of which bones do I need to attach it back to?). Ideally you'd be able to just go into bone tool, hold down a modifier key, and drag the bones around without affecting the sprites or mesh that they are attached to.
    I understand if that is very hard or impossible to do. I'm just stating what the ideal tool would do. :)

    Spine tool looks very cool, thanks!
     
  22. Tannon

    Tannon

    Joined:
    Apr 24, 2014
    Posts:
    9
    Hey Jamie, a couple more bugs to report:

    Since the change to the way the selection works for the bone pivots versus the entire bone, I believe that the way that the vertices are assigned to each bone when a skinned mesh is set up is incorrect. It's assigning the vertices based on the position of the pivot only instead of the length of the bone in general.

    Here's a funny one, I'm finding that the mere act of *selecting* a skinned mesh object with the component "Puppet 2D_Sorting Layer (Script)" is changing it's sorting layer dropdown. If I select it, set the right layer, and deselect it, it's fine. As soon as I select it again it resets to the default sorting layer again. Very annoying.
     
  23. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    Very strange, I seem to be unable to reproduce either of your bugs.

    I did code it to use the centre of the bones for skinning (not the pivot), and it seems to be working in the same way for me. Could you send me a video/images/steps to reproduce it?

    I'm also trying the mesh sorting layer, and its working for me... is this a consistent error? Or is there any steps you do that causes it to start happening?

    Also, if you could try creating a fresh project, download Puppet2D, and see if it happens...
     
  24. Tannon

    Tannon

    Joined:
    Apr 24, 2014
    Posts:
    9
    Ok, we did some more testing and seemed to find the issue.

    The mesh sorting issue occurs in a fresh project if you create a sorting layer above the "Default" layer. Like so: http://puu.sh/9LbyN/61e7683bfc.png

    Then if you select your mesh object and change the sorting layer to "Default", deslect and reselect it you'll notice that it returns to the "Background" layer. So it seems that selecting "Default" from that menu somehow sends no value, so it defaults to the highest in the sort list.

    -------

    I also solved the incorrect vertex weight issue, but it turns out I did something stupid. I wanted to use the mesh deform from bones using Puppet2D but I wanted to animate the bones with physics, using Physics2D hinge joints to apply wind. When I set up the bone structure for the tree here I created the bones and then *removed them from their child-parent heriarchy*, wanting them to be connected just by the hinge joints. Turns out if you do that, it drastically changes the way the vertex weighting occurs:

    http://puu.sh/9Lccb/22c3d13dbf.jpg

    Notice that the mesh is deforming in a way not congruent with the bone movement.
     
  25. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,349

    Hi

    I just donwnloaded and run the latest version and get a problem in the demo, i have not done anything else than just run it first time.

    The polygons seem to go crazy
     
  26. Tannon

    Tannon

    Joined:
    Apr 24, 2014
    Posts:
    9
    Nasos- Try going into Edit-Project Settings-Quality and set the Blend Weights (Under Other) to 2 Bones.
     
  27. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,349
    Fixed it, thanks :)

    Is there a reason we might need this setting on 4 btw ? I use both 3D and 2D models in the scene

    4 bones means it looks for weights further in 3D models ?
     
  28. SFvdB

    SFvdB

    Joined:
    Mar 10, 2014
    Posts:
    28
    Beautiful plugin, I am chuffed to bits with it - especially coming from an After Effects background. I have to even mention that it works better than the 2D IK plugin for AE (called DuDuF IK or DuIK). Yes, that one's free, but still :)

    The flip checkbox is also a fantastic addition, saves me code and makes it so easy.

    One niggle I have is with the size sliders for the controls and bones, it seems impossible to manually enter a number and it is hard to drag it - it doesn't work smoothly as it updates.

    Other than that, consider Puppet2D also plugged on Twitter (@SFvdB). Great job!
     
  29. Tannon

    Tannon

    Joined:
    Apr 24, 2014
    Posts:
    9
    Yes, more bones on this setting could enhance other systems that use bones. I'm not sure if there's a way to keep 4 for some systems and use 2 for Puppet2D...
     
  30. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,349
    I had not even noticed this seeting TBH :), i wonder if there would be a big difference using the 2 bone option
     
  31. C-Castillon

    C-Castillon

    Joined:
    Jun 27, 2014
    Posts:
    1
    Good day sir,

    IF I use this tool and animate a character, and then make a package(export) of the character sprites/scipts/animation.

    will my created package still work if i send it to another developer who does not have the Puppet2d Plugin(he has not bought it)?
     
  32. SFvdB

    SFvdB

    Joined:
    Mar 10, 2014
    Posts:
    28
    Hello Jamie!

    I am having the same issues with lighting. Is it possible to also flip the normals? In any case I am curious about the possible fix.
     
  33. coshea

    coshea

    Joined:
    Dec 20, 2012
    Posts:
    319
    hi all

    i just released an app that uses puppet2d for animating bendable body parts (legs, tail, neck)



    Here is a debug view showing the puppet bones
    http://instagram.com/p/pvqZCpjbhP/

    best
    chris
     
  34. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    To manually enter the numbers, click on the number and press enter, type your number and press enter again. That seems to work for me.
     
  35. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    You can change the number of bones manually on each mesh - try selecting the PuppetMan_body_GEO and in the inspector under quality you can choose 2 bones.
     
  36. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    You can use 4 bones with puppet2D, only you need to make sure you assign all 4 bone weights correctly. The Puppet2D demo character has only been weighted properly to 2 bones, thats why it breaks on 4 bones.
     
  37. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    If you package export it, Puppet2D would be exported with it, and so you would essentially be giving Puppet2D to them.

    There is feature in Puppet2D that you could use to share your animations with non puppet2D users, its called "Bake Animations".

    What you will want to do is bake all your animations onto the bones, and then remove all the Puppet2D scripts and controls from your setup. You can then remove puppet2D completely from the project and share it with another user.
     
  38. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    Essentially the problem comes from the way I'm flipping the character in order to fix a 2D rigid body flipping error.

    If you send me your invoice (to puppet2d@gmail.com) Ill send you ta fix for the normals, only you wont be able to flip characters 2D rigid bodies and colliders
     
  39. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    Awesome!
     
  40. SFvdB

    SFvdB

    Joined:
    Mar 10, 2014
    Posts:
    28
    Thanks! I do appreciate your quick response!

    Right now, though, I use flipping to move my character from left to right (platformer).

    I've been looking at flipping or reversing normals, so far this goes a bit beyond my knowledge though.
    http://wiki.unity3d.com/index.php/ReverseNormals
    So far, though, I have not been able to get this work on the one part of my animated character that uses the mesh.

    Another possible direction I found is perhaps to do with shaders and their culling. Again, though, this is beyond my realm of expertise, really. But tbh it looks like this is not the way to go.
    http://docs.unity3d.com/Manual/SL-CullAndDepth.html

    Would this be helpful in building a workaround or built-in function?
     
  41. Vinous

    Vinous

    Joined:
    Jun 27, 2014
    Posts:
    10
    It looks pretty cool and I would like to have a question about it if it's not a problem :). How did you animated the mouth? Did you use a line of bones with IK control?
     
  42. SFvdB

    SFvdB

    Joined:
    Mar 10, 2014
    Posts:
    28
    Ha Jamie! I did it - without the fix or quoting out code. The process is even quite simple, however you do need (an) extra sprite(s).

    The following works if you:
    • Want your puppet's parts to accept lights
    • Want to use one (or more, though untested) meshes in the puppet
    • Use the Flip function of the Global Control with your puppet's movement (for example, moving on the horizontal axis in the negative direction calls a Flip() function).
    Now, the problem: Non-mesh flipped sprites work just fine, accepting lights. However the problem is when flipping meshes, they disappear or do not accept lights.

    To solve it, what I did was this.
    1. Create flipped versions of the sprites in your dopesheet you want to use a mesh on
    2. Set up your puppet with bones as you would normally do - with only the sprites that constitute the puppet facing one direction.
    3. Change the shader on the sprites and meshes to sprites/diffuse (that way they will accept lights).
    4. When your puppet is done (all the bones and controllers are in place and you're satisfied with these) - click on the Flip checkbox in the Puppet2D Global Control
    5. Insert all the flipped sprites into your scene and convert them to meshes. Make sure they are in the correct place on the Z axis! You'll want them basically at the same z-position as their flipped versions.
    6. Again don't forget to also change their shaders to sprites/diffuse.
    7. Bind them to their respective bones.
    8. Turn off the Skinned Mesh Renderer component on all of the opposite facing parts
    9. Uncheck the Flip checkbox
    10. In the code you use to control the puppet, what I did was enabled and disabling the meshes when facing left or right. So the Skinned Mesh Renderer on left facing mesh would be turned off, and the Skinned Mesh Renderer on the right facing mesh would be turned on, when the puppet moves to the right. And vice versa.
    This worked for me. Here are 2 screenshots of my test character in a simple scene with 1 red light object. Its body is the mesh in question. No problems with the colliders or bones or other parts of the puppet messing up. :D

    See the attached image:
    unity_puppet2d_flipsolution.jpg
     
  43. AlGerbaz

    AlGerbaz

    Joined:
    Jun 29, 2014
    Posts:
    8
    Been playing with Puppet2d a few days. Very nice! Toggling the flip bool on the Global_Ctrl seems to work well in making the character switch directions. Although I've noticed a couple of things. First, the z value creeps up with each flip, and second, the x value jumps around a bit. Not sure if this is something to do with pivots or what. Probably something basic I'm not aware of. Thanks for any help.
    Sorry, I think the x value is moving because the character is walking! But the flip still has the effect of teleporting him a short distance before he starts to walk.
     
    Last edited: Jun 29, 2014
  44. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    The teleporting is probably because your global_CTRL pivot isn't central to the character. To fix this you will want to unparent everything from the global_CTRL, move it to the bottom centre of the character and reparent everything back.

    Not sure about creeping numbers - let me know they are causing you any issues.
     
  45. AlGerbaz

    AlGerbaz

    Joined:
    Jun 29, 2014
    Posts:
    8
    Perfect, thanks Jamie. Having centred the pivot, the z value creep is still happening but it's mainly when walking left. Probably related somehow. Anyway not a major issue in 2d.
     
  46. Arx

    Arx

    Joined:
    Jan 28, 2014
    Posts:
    22
    Hi jamieniman and other Puppet2D users!

    We are creating our first 2D platformer game in Unity. Your animation tool looks perfect, but there are few things we'd like to clarify.

    We have an insect-like character, standing on four legs and having two additional hands. We'd like smooth mouse aiming, which means the rotation of the whole upper body would be controlled by mouse.

    Would it be possible to utilize Puppet2D in this case? Would we have to split the whole skeleton to two parts (upper and lower body), create bones for them and animate them separately (perhaps utilizing Blend Trees for the upper body mouse control), or is there any other way of doing this?

    Thank you very much for your time and the hard work you've put into your plugin!
     
  47. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    You can definitely make your rig with as many legs as you need.

    Perhaps for the spine you could try also using an IK control, which you could attach to the mouse pointer for the aiming. (For IK controls you need 3 bones, but you can always have the first and second bone on the same spot, and then ignore the middle bone for the skinning. So your spine bone structure would be HindSpineBone>UnusedMiddleBone>FrontSpineBone, and you would put an IK on the FrontSpineBone)
     
  48. rushzero

    rushzero

    Joined:
    Jul 1, 2014
    Posts:
    2
    Hi,

    i cant select a bone as parent like you shown in your video tutorial.
    If i click on the bone in the inspector i can see for a short time 500ms a script but than is only a bone-point selected..
    Can you help me how i can fix the problem.
     
  49. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    987
    Actually thats not a bug, its an intended change I did in a more recent version, to explain:

    Bones are essentially pivots, the circles at the end are the main essence of the bone. The long white triangles that point to the children are visual selection devices only, they show visually the connection of that bone to its child.

    So the long connections have 2 purposes:

    1) They show you what children a bone has
    2) They are used so that you can easily select the bone in the view.

    In the tutorial, when you selected a bone you would see a selection around the bone pivot and the connection. This meant I could only have one child connection visible. Now you can see as many connections as there are children.

    Hope that clears things up

     
  50. Tannon

    Tannon

    Joined:
    Apr 24, 2014
    Posts:
    9
    After creating many animations for a character, I'm now noticing a massive delay between selecting any game object and the ability to manipulate it (trying to select and move control objects for more animations). As long as 5-6 seconds before I can move or rotate the control object.

    If I turn off animate mode, select and manipulate those same objects there is no delay at all. There seems to be something specific to selecting and moving them in animate mode that's destroying my productivity here.

    Any ideas? It may even be a general Mecanim problem and not related to Puppet2D...


    Update:

    Wow, may have found the problem. We noticed that every time the character prefab with puppet2D was loaded our version control was saying that the file was modified. It looks like it's been adding lines to the .prefab file for the character:

    http://puu.sh/a49V1/ab60b35014.png
    (This is an open-save-close diff, you can see it's adding things into the prefab without any interaction)

    Also in the .unity scene file it's creating many entries for these created objects, tens of thousands of lines of this:
    http://puu.sh/a4arb/31045ad69e.png

    In all of the edits and commits we've been doing, it's up to 26,000 lines of these. I'm certain this is causing the slowdown. Here's the files if you'd like to take a look:

    https://dl.dropboxusercontent.com/u/153560/CharacterBarneySide.prefab
    https://dl.dropboxusercontent.com/u/153560/CharacterAnimationSetup.unity
     
    Last edited: Jul 9, 2014