Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

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:
    783
    Oooh I like the style of the game :)

    Hmmm - are you using the latest version of Puppet2D? (I haven't seen that bug before - are you getting it only when you use Puppet2D with AC or does it happen elsewhere?)
     
  2. iKonrad

    iKonrad

    Joined:
    Jun 23, 2013
    Posts:
    180
    Thanks! (on behalf of the game artist ;))

    Yes, I use the very latest version (1.10 i guess).

    Actually I had to make a little adjustment to the "Aim Direction" variable.
    I changed it to:
    p.AimDirection = newVector3(1,0,1);

    as when Z value was <0, hands got rotated and were invisible from a normal perspective:

    Screen Shot 2014-08-21 at 17.55.31.png Screen Shot 2014-08-21 at 17.54.07.png

    Oh and my current Hierarchy set up is as follows:

    • Global_CTRL
      • Container (for AC to control the character scale)
        • Offset (to scale the whole character by a certain pivot point (foots))
          • All controls
          • Skeleton
          • Meshes

    I guess the issue doesn't exist in a clear project.
     
    Last edited: Aug 21, 2014
  3. TheWarper

    TheWarper

    Joined:
    Nov 3, 2013
    Posts:
    88
    Jamie, is there any known way to apply your flip setting to an entire animation? For instance, I made a humanoid walk animation to the left, and I would like to push the flip button (in code) and have the animation change to the right, is this possible, or can this be made possible?

    @raGameDev
     
  4. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    783
    You can use:
    Code (CSharp):
    1. GetComponent<Puppet2D_GlobalControl>().flip = true;
     
  5. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    783
    Perhaps I shouldn't have left the aim direction a public variable :)

    Could you elaborate on what was going wrong that led you to change the aimDirection?
     
  6. SeTHBeaRzz

    SeTHBeaRzz

    Joined:
    Jan 8, 2014
    Posts:
    35
    Hey there jamie, I'm facing a problem while using the puppet2D with mecanim.

    here's the situation,
    I'm currently doing an animation where by the character would transform before performing an attack.
    I've achieved this by changing the Material of the mesh created using puppet2D, and it works fine.
    When the character gets hit by an enemy, I made it so that the character would blink, I achieve this by swapping the materials of the meshes to an empty material back and forth.
    The problem arises after I've done that transformation attack sequence whereby my method of making the character blink stops working properly, the material would not change to the empty material specified in my method, particularly the mesh's material which I've change specifically for the transformation attack. When I delete the material property from the transformation attack animation in mecanim, the blinking method works fine again.

    Any ideas?
     
  7. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    783
    I'm not sure what exactly is causing it go wrong - perhaps you could try turning the spriteRenderer on and off instead (or the skinnedMeshRenderer if its a skinned mesh)?
     
  8. TheWarper

    TheWarper

    Joined:
    Nov 3, 2013
    Posts:
    88
    Ah, so that is actually what I am doing, but it still leaves the animation unchanged while in Play mode.

    If I push flip in Edit mode (all of the bones and controls are flipped properly) and run the animation, everything works as expected. However, changing flip via GetComponent<Puppet2D_GlobalControl>().flip = true
    in Play mode has no effect.

    Also, disabling the animator component allows the flip to work again.
     
    Last edited: Aug 23, 2014
  9. SeTHBeaRzz

    SeTHBeaRzz

    Joined:
    Jan 8, 2014
    Posts:
    35
    Hmm... its either something wrong with mecanim or something.
    How would you suggest to go about making a character blink several times rapidly after getting hit?
     
  10. SeTHBeaRzz

    SeTHBeaRzz

    Joined:
    Jan 8, 2014
    Posts:
    35
    I can't use turn the skinmesh renderer on or off because of the same problem. One of my animations require a very unique body pose, so what I did was I created a sprite image of the desired body pose and turned off the skinmesh renderer in mecanim's animation. And with this, I can no longer turn off the skinmesh renderer as long as that property key is in the mecanim's animation.
     
  11. Tommassino

    Tommassino

    Joined:
    May 25, 2014
    Posts:
    7
    Hey, how are you.?

    I am having strange problem and I cant figure it out neither find an answer on the internet.

    I have simple script whis moves character to position where i clicked on the screen. After i switched animating my character to Puppet2d my character sprites dissappears after while. I hope it is easier to understand via pictures I attached.

    missing_sprites_0.png missing_sprites_1.png
     
  12. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    783
    Thats right - you can't both animate something and change it in code I think. Are you able to animate one thing such as the skinnedMeshRenderer, and code change the enabling of the gameObject?
     
  13. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    783
    My first thought is this - make sure your skinnedMeshRenderer has "Update When Offscreen" ticked
     
  14. Tommassino

    Tommassino

    Joined:
    May 25, 2014
    Posts:
    7
    It is working, thank you very much for quick answer :)
     
  15. SeTHBeaRzz

    SeTHBeaRzz

    Joined:
    Jan 8, 2014
    Posts:
    35
    Regardless of changing it in code or animation, as long as the property is in animation, I wouldn't be able to change it.
    So I'm at a lost as to how to approach this problem, it seems to be a problem with animation itself.
    How would you recommend a user of your plugin implement a blinking feature when the character gets hit by an enemy?
     
  16. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    783
    You either want to use a unique property that doesn't have keys in the animation, or you can make use of animation layers:

    http://unity3d.com/learn/tutorials/modules/beginner/animation/animator-controller-layers
     
  17. Keith90

    Keith90

    Joined:
    Sep 27, 2013
    Posts:
    116
    First, I want to say that Puppet2D is awesome. I really appreciate the work into it.

    However, I seem to come across a problem that I hope you can help me with.

    I made animations and Unity told me I had to set them to legacy so I did that. To test if the animations worked, I have it so when I press a button, it plays an animation. The problem arises when I switch the animations and it seems to continue exactly from where the pose was.

    For example, if I press A and the character is moving down to jump then I press D to make the character walk, the character plays the walking animation from whatever height they were at while moving down, which messes up the animation.

    Is there a way to fix this?

    I appreciate any advice/information you can give me.

    Thanks. :)

    Edit: The code is basically:

    if(Input.GetKey (KeyCode.D)){
    animation.Play ("Jumping");
    }

    I have that for each animation. Could that be the reason why?
     
    Last edited: Aug 26, 2014
  18. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    783
    Make sure the same properties are keyframed on both animations - so it can set the keys correctly when you change animation.
     
  19. Keith90

    Keith90

    Joined:
    Sep 27, 2013
    Posts:
    116
    So whatever I move in one animation, I must move in another?
     
  20. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    783
    at least have keyframes for it, if it doesn't start and end with the same pose
     
  21. Keith90

    Keith90

    Joined:
    Sep 27, 2013
    Posts:
    116
    Ah, alright. I'll give that a shot. Thanks. :)
     
  22. coshea

    coshea

    Joined:
    Dec 20, 2012
    Posts:
    256
    Has anyone done a 2d ragdoll with puppet2d yet? So you have your animated walk cycles, but then if your character falls its legs/arms etc flail around?
     
    TheWarper likes this.
  23. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,317
    I tried publishing the example project to Iphone 4 and getting a strange behaviour. The character is stationary and the control points are animated. How to get the character to move along with the animation points.
     
  24. mccann

    mccann

    Joined:
    Sep 24, 2013
    Posts:
    29
    I have a slight issue that is making it hard to animate my character.

    In the editor when trying to fine tune the animation, I grab the Puppet IK control to move the foot and the corresponding bone/graphic flickers to another location and makes it hard to visually edit. The other location is always a 'valid' location based on the bone constraints, but it is not where the IK control is located. When I click on something else (like another IK control or click play to show the animation), everything looks fine.

    When I run the animation through the game, it does appear that the IK control "slips" and is not connected to the bone/graphic. So the "walk" animation via the Dope sheet looks fine, but the Game animation looks bad.


    Defect? Or some other issue?

    Video to see what I'm talking about:
     
    Last edited: Sep 1, 2014
  25. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    783
    For some reason it sounds like the scripts have stopped updating - have you seen any errors? Check out you global_ctrl, is it enabled with all the controls in their attribute lists?
     
  26. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    783
    It looks like you have some keyframes on the control groups (footL_CTRL_GRP)- perhaps they are causing issues? Try removing them (only have keyframes on the controls themselves).

    Also make sure you don't have any keyframes on the bones that are controlled by IKs.
     
  27. mccann

    mccann

    Joined:
    Sep 24, 2013
    Posts:
    29
    I removed the bone keyframes (which were on the upper part of the leg - was trying to capture the 'hip movement'), but I still have the same issue on the in game render view. Other thoughts?

    Also, in your Puppet2D Tutorial video, @ 2:30, you show clicking on the spine then starting the arm bones. That didn't work for me. In doing so, it builds a bone from spine to arm (even though I had stopped the bone creation tool). I don't think this is related to the above issue for me since the arms work and I just parented the objects under the spine in the Hierarchy later... but thought it would be worth mentioning.
     
  28. Watapax

    Watapax

    Joined:
    Sep 3, 2013
    Posts:
    34
    This asset is Awesome, super Fast to setup a simple rigg. But i would like to have more control over the generated mesh, for example, add more vertices manually and set the position over that vertices manually, this in order to have more control when the sprites Bend. This is a feature that Spine have and work perfectly.
     
  29. Keith90

    Keith90

    Joined:
    Sep 27, 2013
    Posts:
    116
    When I flip my character, instead of flipping in place, he moves off to the right or left when he flips, creating noticeable distance when he flips. How would I fix that?

    Edit: It seems that it has to do with the character not being in the middle of the gameobject. Is there a way to move all the children to the middle so that way it flips on the spot?

    Edit: Is it possible to create another puppet and apply animations from a different puppet to the newly made one? or do the animations rely on the original puppet?
     
    Last edited: Sep 2, 2014
  30. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    783
    FFDs are almost ready - I'm just doing the final bug fixes and promotional material, and it will be out soon.

    If you'd like to try a beta version please email puppet2d@gmail.com your invoice and i'll send it over :)
     
  31. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    783
    All you need to do is unparent everything from the global_Ctrl, move the global_Ctrl to where you want the flip point to be and then repraent everything back.

    The animations require the names and hierarchy of the controls to be the same to work.

    If you have animated controls only (not the bones directly), they may even work when the controls have different start transforms. This is because the controls all start at zero transforms, and their starting positions come from the offset groups.
     
  32. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    783
    The hip bone shouldn't have been a problem (I do recommend making parent controls for these though, controls start from zero transforms so they are much cleaner to work with - you can reset them by zeroing their transforms)

    I think the problem might be the keyframes you have on the control groups - these are the gameobject parents of your controls. Have you removed the keyframes from these groups? (Make sure you only keyframe the controls not the controls parents)

    If thats not it, could you package up your character and send him to puppet2D@gmail.com so I can take a closer look

    This isn't a bug - its actually a fix, let me explain.

    Essentially a bone is visual pivot point. The "joint" part of the bone shows you the hierarchy of the bones and helps you to select the bone.

    In an earlier version of Puppet2D (as in the tutorial) you could only see the joints to a single child, thats why you got a gap between the spine and the shoulder bone. This was a visual bug. You should always be able to see which bones are parented to which bones, thats a big purpose of them being there.

    In any case the functionality hasn't changed. Hope I explained that clearly :0)
     
  33. Keith90

    Keith90

    Joined:
    Sep 27, 2013
    Posts:
    116
    I'm going to rebuild my character. It seems I have made a few errors regarding it, such as animating the CTRL_GRPS.

    In regards to the global_CTRL, how come it seems to go to 0,0?

    Thanks for all your help. :)
     
  34. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    783
    You should ideally rig the character so that pivot is at 0,0, thats the cleanest way to make your character. That way you can animate it at the origin, and offset it within another gameobject.
     
  35. mccann

    mccann

    Joined:
    Sep 24, 2013
    Posts:
    29
    @jamieniman - I emailed my animation / assets to you.

    Ah! That does clear things up. Maybe update the youtube with comments to explain what is different / changed?


    One more question - if you want to animate multiple characters using the tool, I'm guessing each one needs its own Global_CTRL? (copy/paste and retarget elements to new character or is there an easier way to spawn a 'new character'?)
     
  36. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    783
    If you want them to share the same animations you can skin the new character to the bones of the same rig.
     
  37. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    783
    Hi everyone!

    Heres a sneak preview of some of the features soon to be released as part of Puppet2D v2.0:

     
    mccann likes this.
  38. rushil133

    rushil133

    Joined:
    Nov 21, 2012
    Posts:
    19
    @jamieniman i am using your puppet 2d plugin & currently facing small issues with rigging , i am trying to setup bones but it does not take the object when i click on parent object to the bones.I have done all the arrangements of sprites properly but couldn' t find the solution.

    You can also view the video showing the above issues from below link:-


    Kindly guide me to slove the above issue!!
     
  39. mccann

    mccann

    Joined:
    Sep 24, 2013
    Posts:
    29
    I'll see if I can answer this (especially since I'll be asking more questions too)...
    It is hard to see the bones in your video. but the bone hiearchy window shows the RightHand_upper parented to the armR -- move it to the elbowR.... i think that would fix it. Also, this might have happened due to the position of your joint (not sure).

    Nice graphic btw.
     
  40. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    783
    The "Parent Objects To Bones" tries a best guess at parenting your sprites to the bones - it finds the closest bone to the centre point of the sprite. This works around 80% of the time, if it doesn't pick the right one you just need to move it to the correct bone yourself. As @mccann said parent LeftHandL_upper to armL and that should fix it :)
     
  41. mccann

    mccann

    Joined:
    Sep 24, 2013
    Posts:
    29
    My question was regarding a completely new character / animation setup... so, I would need a new Global_CTRL, right?

    Regarding your comment, I need to know how to do this though; however, I'm not sure how one would "skin the new character to bones of the same rig" without colliding in the same visual space as the previous graphics. Can you give more detail?

    So, if we can easily reuse bone animations, something else we should probably do as a community is build good looking animation loops with the bones, share them, and then others can skin them as desired.

    What advise can you give regarding using Unity's 2D physics with Puppet2D? (tried doing something simple - enabling gravity on the character, but it didn't work.)
     
  42. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    783
    You could use a new Global_CTRL or you could use the same one, nad in code turn on and off the different meshes to choose the correct one.
    You need to change the "Order in Layer" on the spriteRenderer. Also, if u are creating them dynamically in code, its a good idea to spawn them with a large offset on this value eg OrderInlayer +100 each time

    Lovely idea. Would need to agree on a perfect biped rig that everyone gets on board with though :)

    Depends on what you are trying to specifically - you need rigidBodies on the parts that are dynamic. If you want to do rag doll stuff, you will need to disable the global_CTRL so that the bones dont move with the controls.
     
  43. Keith90

    Keith90

    Joined:
    Sep 27, 2013
    Posts:
    116
    How would I make the rigidbody using the bones?

    Would I make a normal puppet, then disable the global_CTRL object or script? I assume I need to have a rigidbody, hinge joint and a collider on each limb if I want it to fall and interact with other things. Am I on the right track or completely wrong?
     
  44. mccann

    mccann

    Joined:
    Sep 24, 2013
    Posts:
    29
    The ball is in your court. Maybe do a contest and then vote? or if you have the skills?

    Ragdoll stuff would be good too. I was trying to have my character run on a 2d 'ground', but was unable to have Unity gravity be utilized. I read through the previous 10 pages of comments last week on this forum and don't remember anyone asking about this (which I find strange). When you say "rigidBodies on the parts that are dynamic" - which parts specifically? In my tests, it would appear that I can attach boxcolliders to the sprites, but can't attach rigidbodies to anything without it messing up the animation.

    If you have a working example we can download, that would great! :)
     
  45. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    783
    Yup, I decided to make a quick video showing me set it up. As you said - you need to disable to global_Ctrl for it to work. You will also want to limit the x & y rotations and z position.
    On the Puppetman demo character it breaks on the elbow for some reason - so I needed to change the settings slightly.

    @mccann @coshea here it is:

     
  46. Keksmanu

    Keksmanu

    Joined:
    Jul 11, 2014
    Posts:
    11
    Is there also an option to mirror the animations made with a bone character?
     
  47. Keith90

    Keith90

    Joined:
    Sep 27, 2013
    Posts:
    116
    Thanks for the video.

    I guess this isn't possible using 2D Physics. I'll have to reconstruct my character and see if I can still achieve what I want. It shall be interesting to have 2D art and use 3D physics objects.

    Keksmanu use:

    GetComponent<Puppet2D_GlobalControl>().flip = true;
     
    Last edited: Sep 9, 2014
  48. mccann

    mccann

    Joined:
    Sep 24, 2013
    Posts:
    29
    Based on your video, it would seem that 3d rigid bodies work, but you have to disable global_CTRL -- so, 2d physics won't work with the puppet2d animated character... you have to roll your own physics / movement to have both physics and the animation running.... right?
     
  49. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    783
    To get it to behave as a ragdoll you need to disable its controls.
    I think I may have confused with my video - you can certainly use 2d physics with puppet2d, it was just the quickest way to do ragdoll that I know of.

    What kind of physics are you looking for? 2D colliders will work when the character is animated, only getting it to act as a Ragdoll is best for when the character dies or something.
     
    Last edited: Sep 9, 2014
  50. jamieniman

    jamieniman

    Joined:
    Jan 7, 2013
    Posts:
    783
    Apologies for confusing things with my video - you can certainly use 2D physics. Its just for some reason Unity haven't made a automated 2D ragdoll setup as far as I know. (I think there is an asset you can get that does it).
     
    Last edited: Sep 9, 2014