Search Unity

  1. We've closed the job boards. If you're looking for work, or looking to hire check out Unity Connect. You can see more information here.
    Dismiss Notice
  2. Unity 2017.2 is now released.
    Dismiss Notice
  3. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  4. If you're a macOS 10.13 High Sierra user take be sure to read this before updating Unity.
    Dismiss Notice
  5. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  7. Unity 2017.3 beta is now available for download.
    Dismiss Notice

PuppetMaster - Advanced Character Physics Tool [RELEASED]

Discussion in 'Assets and Asset Store' started by Partel-Lang, Oct 1, 2015.

  1. slavaglap

    slavaglap

    Joined:
    Sep 22, 2017
    Posts:
    6
    I did it with "Normal Mode" to "Unpinned"
     
  2. Useless-Media

    Useless-Media

    Joined:
    Apr 19, 2015
    Posts:
    61
    Hello i have a little problem with my Puppet Master.

    I was trying to Lerp the Pin Weight variable to zero while i perform a Jump and i get this behaviour
    lerpPinWeight.gif
    The Ragdoll does its normal awesome stuff but the Character Animator and the Bones dont follow the movement, im using Opsive Third Person Controller

    These are my settings, the one that is changing in runtime is Pin Weight
    puppetMasterSettings.png

    Thanks for your awesome support!

    EDIT: I just need to find a way to update the Character Mesh with the Ragdoll
     
    Last edited: Oct 7, 2017
  3. DiNoGames

    DiNoGames

    Joined:
    Feb 5, 2015
    Posts:
    14
    Hi. How am I supposed to move a rag doll with my mousepointer? In my game I need to switch from animated to ragdoll when mouse is pressed over the character. This works with setting pinstrength to 0. But the rag doll moves independent from the gameobject then and falls down by gravity. I now need to "hook" the rag doll to the mousepointer to move it. How can I achieve this?
     
  4. corjn

    corjn

    Joined:
    Feb 6, 2014
    Posts:
    32

    Thanks a lot Partel, everything is working great now :)
     
  5. slavaglap

    slavaglap

    Joined:
    Sep 22, 2017
    Posts:
    6
    Hi

    And how to check when ragdoll turns on? (with PuppetBehavior Unmapped)


    I tried to use head.state.pinWeightMlp but it is always 1
     
  6. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,498
    Perhaps with something like this:
    Code (CSharp):
    1. muscle.state.muscleWeightMlp = Mathf.Lerp(0.02f, 1f, muscle.state.pinWeightMlp);
    Hey,
    If using BehaviourPuppet, do not set pin weight to 0, call behaviourPuppet.SetState(BehaviourPuppet.State.Unpinned) instead.

    Hey,
    If using BehaviourPuppet, do not set pin weight to 0, call behaviourPuppet.SetState(BehaviourPuppet.State.Unpinned) instead. Then disable behaviourPuppet.canGetUp until you need the ragdoll to recover.
    About moving it with a mouse, make a kinematic Rigidbody object that you can move around with the mouse, then just add a Joint of some kind that connects it to one of the ragdoll's rigidbodies.

    Cheers,
    Pärtel
     
  7. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,498
    check for behaviourPuppet.state. If == BehaviourPuppet.State.Unpinned, then your character is ragdolled.
     
  8. Useless-Media

    Useless-Media

    Joined:
    Apr 19, 2015
    Posts:
    61
    Hey Partel, this was also my first thought to set the puppet to unpinned but later on i was imagine it will be look cooler when the Animation fade out so pinWeight sound for me the better option in this case.
    What can i do when i want use pinWeight instead?


    EDIT: I found out that the system working fine in the Demo and also with a standard Opsive Third Person Character Setup its working that the Mesh follows the ragdoll when you turn down the pinWeight, i dont know what i mess up with my character but its no bug from the Puppet Master
     
    Last edited: Oct 9, 2017
  9. m_katsukawa

    m_katsukawa

    Joined:
    Oct 20, 2017
    Posts:
    2
    Hello Partel-Lang,

    I developed a program with PuppetMaster in Unity 5.4.1.
    After I moved it into Unity 5.6.3, the model controlled by PuppetMaster went down about a meter as shown in the pictures below.

    Could you give me some advice about this?

    Unity 5.4.1
    beforeVersionUp.jpg
    Unity 5.6.3
    afterVersionUp.jpg
     
  10. h00man

    h00man

    Joined:
    Apr 17, 2017
    Posts:
    14
    Hey partel,
    thanks for answering questions.
    i'd be really appreciated if you help me too.
    how can i switch the state of puppetmaster from alive to dead when my character collides with an object.
    let's suppose my character's body hits a spear or a knife, after the hit i want alive mode to be switched with dead mode.
    how can i achieve that throw script?
    thanks
     
  11. staron82

    staron82

    Joined:
    May 22, 2017
    Posts:
    9
    Has the behaviors section of puppetmaster, where you set up walkable and collision layers, been removed?
     
  12. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,498
    Hey,
    No idea, haven't seen anything like that, but I doubt it is a PM issue. Is the entire character sunken or just the ragdoll in play mode?

    Hey,

    So you should make a script that uses the BehaviourPuppet.OnCollisionImpulse delegate to get information when the puppet collides with a spear or a knife:

    Code (CSharp):
    1. public BehaviourPuppet puppet;
    2.  
    3.     void Start() {
    4.         puppet.OnCollisionImpulse += OnCollisionImpulse;
    5.     }
    6.  
    7.     void OnCollisionImpulse(MuscleCollision m, float impulse) {
    8.         ///if (m.collision.gameObject.layer == knifeLayer) ...
    9.         // if (m.collision.gameObject.tag == knifeTag) ...
    10.  
    11.         puppet.puppetMaster.state = PuppetMaster.State.Dead;
    12.     }
    Hey,
    No, they are under BehaviourPuppet, not PuppetMaster.

    Best,
    Pärtel
     
  13. h00man

    h00man

    Joined:
    Apr 17, 2017
    Posts:
    14
    Thanksssssssssss, it works :D
    i was wondering, what's the best way to connect my character to an object ?
    i have a character with puppetmaster applied to it and i want to connect my character to a skateboard and riding it and when he hits an obstacle he would fall down off the skateboard.
    but the problem is when i'm trying to connect them throw child and parent relationship
    and hit play.... my character shows some really strange behaviors, like flying into the air, or going down under the ground or spining madly .
    i have also tried to contact them by fixed and character joint but still pretty much the same results.
    i have no idea what's wrong
     
  14. m_katsukawa

    m_katsukawa

    Joined:
    Oct 20, 2017
    Posts:
    2
    Thank you for your reply.

    I moved a model with animation (before installing PuppetMaster) from Unity 5.4.1 into Unity 5.6.3, and I found it was sunken.
    So I think it is not a PuppetMaster issue.

    I'll check model, animation and Unity manual to find the cause of it.
     
  15. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,498
    Hey,
    Parenting should be fine, just make sure to unparent when the character loses balance. Otherwise the ragdoll will be parented to an object that is separated from it and moving/rotating independently and that would indeed mess up the physics I imagine.
     
  16. matteumayo

    matteumayo

    Joined:
    Jul 25, 2016
    Posts:
    93
    Hello,

    I'm encountering an error with the Joint Break method of muscle removal. This is using Unity 5.6.4 and I believe the newest PM version.

    When I go to the demo scene and set a joint break of 0.001 so it instantly breaks, I get these errors:

    [​IMG]

    Two for each limb in the chain after joint-breaking the upper right arm. (Each child of the joint broken)

    Full text of first error: https://pastebin.com/Au7iWAZP

    Further, on collision, the removed muscle throws this error:

    [​IMG]

    Full text: https://pastebin.com/4srZ78sq

    This also happens with my own PM setup.

    Thanks for any help.
     
  17. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,498
    Hey,
    Looks like a bug already fixed for the next version. Contaced you in PM.
    Cheers,
    Pärtel
     
    matteumayo likes this.
  18. Useless-Media

    Useless-Media

    Joined:
    Apr 19, 2015
    Posts:
    61
    Hello,

    I got this 2 errors at runtime when i am working with my uma character sometimes puppet2.png
    puppet1.png
     
  19. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,498
    Hey,
    Is there a specific scenario at which this happens or does it happen just randomly? Are you using BehaviourPuppet and what is the state of the puppet (pinned, unpinned or getting up) when it happens?

    I'm out of office next week, I'll take a look at it in depth as soon as I'm back.

    Best,
    Pärtel
     
  20. Useless-Media

    Useless-Media

    Joined:
    Apr 19, 2015
    Posts:
    61
    the puppet is pinned, with default settings on the puppet master and this settings on the BehaviourPuppet
    puppet.png

    I generate my character with UMA with the BuildUMAPuppet.cs for the DynamicCharacterAvatar.cs

    The bug is not annoying, he pops up sometimes when i walk

    Mostly the error comes when the Foot hits a object with a different angle of his face then the previous
     
    Last edited: Nov 6, 2017
  21. Ragoo

    Ragoo

    Joined:
    Feb 15, 2014
    Posts:
    57
    Hi Partel,

    There is an offset in the upper body whenever the puppet gets unpinned:

    upload_2017-11-9_0-48-16.png

    I have no idea what's causing it, there is no IK active on the body. Any idea what could be causing it? The mapping weight for all muscles is at its default of 1.

    EDIT: Whenever I enable 'Map Position' for the misaligned muscles it fixes the issue - is this intended/desired behaviour?
     
    Last edited: Nov 8, 2017
  22. h00man

    h00man

    Joined:
    Apr 17, 2017
    Posts:
    14
    Hi Pärtel,
    How can i determine my character is in the air and fall down from sky?
    i have a ragdoll character and and i want to release him from roof top a building.
    how can i tell the character if he is in the air for more than 2 seconds , then the behavior fall should be playing ( i also have an falling animation and i want the animation to be played while falling).
    thanks.
     
  23. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    352
    Partel,

    I'm still dealing with the issue of when props are dropped to the terrain, they do not come to rest. We had a private conversation back in July on the subject and you determined that it was a floating point precision problem with physics on terrains where the further props are dropped from world origin the more problematic they are. I've tried dozens of solutions and nothing works. Adjusting Rigidbody.sleepThreshold, mass and friction, changing the size of the prop colliders over time etc. etc. I am unable to find any consistent way to get props to come to rest when dropped on terrain.

    I was wondering if you could provide a patch or an update that has the option to Destroy the configurable joint when dropped and Add it when picked up for props. You do something similar when using Grab in the Melee Grab demo so I'm assuming this would work for props.

    Thanks
    Allan
     
  24. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,498
    Hi all, sorry for the delay, I'm back in office now..

    Hey,
    Does it still happen when you comment out line 678 in Muscle.cs?

    Hey,
    It can happen when you have animation on one of the spine bones that is not part of the ragdoll. If you see this, enabling "Map Position" for the spine muscles is the correct solution.

    Hey,
    You could just raycast down from the root of the character and if that distance is beyond of which he can recover from (like 3 meters or whatever), call
    Code (CSharp):
    1. behaviourPuppet.SetState(BehaviourPuppet.State.Unpinned);
    Just make sure that raycast does not hit the character controller or the ragdoll layers.

    Hey,
    Do the props come to rest when there is no ConfigurableJoints attached to them?

    Cheers,
    Pärtel
     
    Ragoo likes this.
  25. h00man

    h00man

    Joined:
    Apr 17, 2017
    Posts:
    14
    thanks man.
     
  26. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    352
    Partel,

    Good question. Actually no they keep bouncing around even when I manually remove the ConfigurableJoint. I'll try multiplying mass by 10 when dropped and go back to default when picked up. That seems to help.

    Allan
     
  27. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,498
    Hey,
    Could also try adding a script when they are dropped, that checks for rigidbody.velocity.sqrMagnitude and if that's below a threshold for a sec or so, call rigidbody.Sleep();
     
  28. RakNet

    RakNet

    Joined:
    Oct 9, 2013
    Posts:
    69
    In my game I might have an enemy that is lets say 10 degrees to the left. I want to rotate the character's chest 10 degrees to the left, so his sword hits the enemy. This is a relative adjustment to the IK, where all the usual values are the same, but rotated left around the chest by 10 degrees.

    I tried to do this with AimIK, but the problem is that AimIK is absolute (look at this fixed point throughout the animation) rather than relative (look left throughout the animation). I guess I could make some child node on the character, orient it 10 degrees to the left, and have AimIK look at that.

    But is there an easier way?
     
  29. Useless-Media

    Useless-Media

    Joined:
    Apr 19, 2015
    Posts:
    61
    I did not see the error a while now but i comment line 678 out and tell you when something pops up
     
  30. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,498
    Hey,
    Please take a look at the "Aim Swing" demo:

    Code (CSharp):
    1. public AimIK ik;
    2.         [Tooltip("The direction of the animated weapon swing in character space. Tweak this value to adjust the aiming.")] public Vector3 animatedSwingDirection = Vector3.forward;
    3.  
    4.         void LateUpdate () {
    5.             ik.solver.axis = ik.solver.transform.InverseTransformVector(ik.transform.rotation * animatedSwingDirection);
    6.         }
     
  31. Useless-Media

    Useless-Media

    Joined:
    Apr 19, 2015
    Posts:
    61
    Hello Partel,

    I saw the error today again p.png

    Comment out the line 678 in Muscle.cs does not help
     
  32. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,498
    Hey,
    Sorry to bounce you, but could you add this to line 679, it should log a bunch of variables right before that error pops up, please give me a screenshot of them the next time you see the bug:

    Code (CSharp):
    1. if (float.IsNaN(force.x) || float.IsNaN(force.y) || float.IsNaN(force.z)) {
    2.                 Debug.Log("[Muscle] positionOffset.x: " + positionOffset.x);
    3.                 Debug.Log("[Muscle] positionOffset.y: " + positionOffset.y);
    4.                 Debug.Log("[Muscle] positionOffset.z: " + positionOffset.z);
    5.                 Debug.Log("[Muscle] fixedDeltaTime: " + Time.fixedDeltaTime);
    6.                 Debug.Log("[Muscle] w: " + w);
    7.                 Debug.Log("[Muscle] rigidbody.velocity: " + rigidbody.velocity);
    8.                 Debug.Log("[Muscle] pinDistanceFalloff: " + pinDistanceFalloff);
    9.                 Debug.Log("[Muscle] positionOffsetSqrMag: " + positionOffset.sqrMagnitude);
    10.             }
    Thanks!
    Pärtel
     
  33. bhudson

    bhudson

    Joined:
    Nov 21, 2014
    Posts:
    9
    I added a rewind button: hit the button and poof my animation goes back to frame 1.

    When I do that, PuppetMaster goes completely bonkers; my character does this bizarre dance with all the limbs and head orbiting the pelvis, and the solver never reaches quiescence. Looks quite painful. I presume it's that all the velocities are messed up because I teleported everything.

    Is there an ideal way to reset PM's internal state, short of deleting the rig and re-creating it?

    EDIT: if I explicitly set the muscle transforms to match their targets in the frame that I teleport, seems to work great:

    Code (csharp):
    1.  
    2. foreach(var muscle in m_puppet.muscles) {
    3.   muscle.joint.transform.position = muscle.target.position;
    4.   muscle.joint.transform.rotation = muscle.target.rotation;
    5. }
    6.  
     
    Last edited: Nov 21, 2017
  34. Filhanteraren

    Filhanteraren

    Joined:
    May 14, 2014
    Posts:
    32
    Hi, I am looking to use Puppetmaster in my project but is a bit concerned about performance. I will use it for Enemy AI and on a normal level there can be up to 30 enemies. Now you never see that many at the same time, the maximum is around 10 that are visible at the same time. In normal mode the puppetmaster is set to disable(they get activated they die etc.) Looking at the profiler the PuppetMaster.LateUpdate takes around 5-8ms for all of the enemies(on a low target platform)

    What I wonder if there is any good optimization that can be done to puppets outside of view? I already did all the suggestion on the optimization page and that helped but I would like to further get the time down.
     
  35. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,498
    Hey,
    Have you tried deactivating the PuppetMaster gameobject for the ones that you normally disable?
     
  36. charming_fox

    charming_fox

    Joined:
    Apr 4, 2013
    Posts:
    8
    Hello! First can I say, I love this asset, it's excellent. Secondly, I have a question:

    Using the supplied 'User Control AI script, how would I go about triggering the AI to 'Jump'?

    Thank you!
     
  37. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,498
    Hey, thanks!

    As in UserControlThirdPerson.cs:
    Code (CSharp):
    1. state.jump = canJump && Input.GetButton("Jump");
    But instead of Input.GetButton, use a bool function that returns true whenever your AI deems appropriate to jump.
     
  38. charming_fox

    charming_fox

    Joined:
    Apr 4, 2013
    Posts:
    8
    Thank you, i'll give this a go!

    Edit: I can't believe how simple that was, thanks for the quick response!
     
    Last edited: Nov 25, 2017
  39. goravkumar

    goravkumar

    Joined:
    Sep 8, 2017
    Posts:
    2
    Hello @Partel Lang

    I have problem with puppet master that :
    we can't use LookAt method for Puppet victom to keeps looking at the target.
    if i use LookAt on puppet victom parent object then disturb the victom posture.
    so please help me how can i achive victom to always keeps looking at the target.
     
  40. trappist-1

    trappist-1

    Joined:
    Mar 26, 2017
    Posts:
    172
    I am having trouble creating proper ragdolls from Blender models. I have tried exporting the fbx in many ways (including using this fix).

    No matter what I try, I always see that the green axis is sideways:
    [​IMG]

    Compared to the models in your video which all show that the green axis is Up/Down:
    [​IMG]

    The issue it seems to be causing is strange feet placement during a get up animation:


    How do I rotate that green axis? Or do you believe it is even part of the problem?
    Also Is there anywhere I can find information that explains what ragdoll creator expects for proper "input" bone rotations?

    Thanks.
     
    Last edited: Dec 6, 2017
  41. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,498
    Hey, did you mean you can't use Animator.SetLookAtPosition or were you talking about LookAtIK of Final IK?

    Either way, if the puppet is ragdolled or partially ragdolled, you'll need to convert the look at target position to muscle space using the pelvis muscle as reference:

    Code (CSharp):
    1. Vector3 ikPosition = puppetMaster.muscles[0].target.TransformPoint(puppetMaster.muscles[0].transform.InverseTransformPoint(target.position));
    If you were using Final IK's LookAtIK, I suggest you switch to AimIK, it works better in this scenario.

    Hey,
    The ankle joint is a ball-socket type of joint that rotates more or less the same amount around every axis. It doesn't really matter much if the green axis is switched with the blue (can be fixed easily with the RagdollEditor). I can't see the video about getting up, might be set to private.

    Cheers,
    Pärtel
     
  42. trappist-1

    trappist-1

    Joined:
    Mar 26, 2017
    Posts:
    172
    Hey, thanks for the info. And sorry about the video, I think it's fixed now (direct link).
    The reason I asked this is because I placed my model and the pilot model side by side and made them both puppets in the same way, then when I killed/resurrected them the feet on the pilot looked fine while my model looked like it was twisting.

    Video showing two puppets created together in the same way, pilot gets up normally while my model's feet twist a little:


    Upon looking at the bone rotations between the two armatures I noticed that they weren't the same. Also when I turned off angular limits the issue disappears, this is what lead to me suspect the rotation of the joints.

    ---------
    If I may ask one other related question, what is the reasoning behinde why the yellow limit has two handles and can be inverted, while the green and blue limits have only one handle and can't be inverted? I feel as though I don't fully understand the joint limits and why they would ever need to be swapped if it is a ball socket. Like, what is the rule of thumb when adjust the limits (yellow axis is the primary rotation plane)?
    ---------

    [UPDATE]
    After reading this from the docs I decided to open up the limits a little on the knee joints. Which helped, but not until I opened them up completely did it look a little better (still occasional twitching).
    I will try simply widening the limits of all joints on the legs and see what happens. But I still don't understand the purpose of the yellow axis verses the red and blue.

    [UPDATE]
    I left the knee joints default but completely opened the limits on the thigh and foot and still saw the leg twist. Only when I fully open the limits on the knee does it look better, but not perfect. I really don't want to have to disable limits and any suggestions would be nice.
     
    Last edited: Dec 6, 2017
  43. goravkumar

    goravkumar

    Joined:
    Sep 8, 2017
    Posts:
    2
    Partel-Lang,

    I have purchased only puppet master tool.I am using normal transform.LookAt(). So i want to know that how i can archive that my victom player always face towards my camera with puppet master tool. i also see the final Ik package in the integration folder and add into my project but there after have some errors related to Final IK namespace. please help..
     
  44. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,498
    Hey,
    Do both PuppetMasters have the same values under "State Settings"? Looks like to me based on that video that the problem might actually be that the feet don't have much muscle spring so they easily collapse to the limits.

    Oh I see, just use that transform.LookAt() on the target root transform (see "Target Root" under PuppetMaster), not the PuppetMaster transform.

    About that Final IK package, it is just an integration package for FIK, only import that if you have Final IK installed.

    Best,
    Pärtel
     
  45. trappist-1

    trappist-1

    Joined:
    Mar 26, 2017
    Posts:
    172
    Are you referring to the state settings under the puppermaster component? Both are identical...

    I ended up just using the enable angular limits when killed. It's good enough!!
     
    Last edited: Dec 6, 2017
  46. Padilha

    Padilha

    Joined:
    Jun 6, 2016
    Posts:
    4
    I am using Unity 2017.2.0f3 and am having problems in a demo scene.

    In the "Puppet Extended" scene I am trying to turn the character using the A and D keys but the character does not turn, he continues straight even though I keep pressing the keys.

    I do not know if it does not set correctly, I took a quick look but found nothing. I would appreciate it if you could help me, thanks
     
  47. trappist-1

    trappist-1

    Joined:
    Mar 26, 2017
    Posts:
    172
    It's a known bug, Partel has released this patch.
     
    Partel-Lang likes this.
  48. Zrexa

    Zrexa

    Joined:
    Oct 29, 2014
    Posts:
    150
    @Partel-Lang Is there any reason why puppet master would behave differently in editor and build? I have a prefab of a puppet, when I drag 5 of them into my scene, they work fine and normal in editor, but when I build my project, 1-3 of them start going crazy and flying across the scene.
     
  49. trappist-1

    trappist-1

    Joined:
    Mar 26, 2017
    Posts:
    172
    I noticed jumpy behavior from some puppets when I forgot to enable animate physics. Took me a while to realize it too. Perhaps it's something to check..
     
  50. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,498
    Hey,
    Haven't seen that before, made tons of builds of it. Which Unity version are you using and any chance you could send me a link to a repro project to support@root-motion.com?