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

PuppetMaster - Advanced Character Physics Tool [RELEASED]

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

  1. gliealonso

    gliealonso

    Joined:
    Oct 21, 2018
    Posts:
    15
    Hi Partel,


    You know that blue skeleton from Full Body Biped IK? I can't see it anymore:
    upload_2019-10-14_21-26-26.png

    I'm also trying to edit the ragdoll of a character, but it doesn't give me the option to:
    upload_2019-10-14_21-28-23.png


    Gizmo seems to be fine:
    upload_2019-10-14_21-28-42.png
    upload_2019-10-14_21-29-3.png

    Has this ever happened to someone before?

    To try to fix this, I restared my computer, deleted puppetmaster and final ik and updated and reimported it.

    Many thanks,
    Gabriel.
     
  2. BenWoodford

    BenWoodford

    Joined:
    Sep 29, 2013
    Posts:
    74
    Would it be possible to get a way to do sequences when ragdolling a puppet? I know we can manually do the muscle manipulation ourselves but it'd be really nice if we could setup delays on each muscles for how quickly they should ragdoll when an enemy dies. For instance if you shoot someone's head off, the "traditional" death movement would be to have their arms ragdoll, and followed by their legs ragdolling so they fall forward, etc?

    Or is this already possible?
     
  3. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,965
    Hey,
    Not exactly sure what all is going on in that project, but the logic should be like this:
    1. In Update, if mouse button is pressed, you just call anim.SetTrigger("Throw");
    that throwing animation should have an Event "Throw" created at the point in time when the object is tossed.
    2. Add public void Throw() {} to your script, that gets called by the Animator when that event happens.
    3. In that Throw() method, do propRoot.currentProp = null;

    Currently I see you are setting propRoot.currentProp to null at the same time you trigger the throwing animation so that is too soon and so the prop would be thrown before the animation even plays.

    Hey,
    Sure you imported PM and FIK as a whole? I can think of this happening only if someone imported either asset without the editor scripts or maybe moved the editor scripts out of the "Editor" folder.

    Hey,
    Please check out the "Death Procedures" demo and the Dying.cs script. It does that basically, but just not with different speeds per muscle group.

    Check out the private IEnumerator FadeOutPinWeight() and private IEnumerator FadeOutMuscleWeight() on the bottom of the script. They are coroutines that just reduce pin and muscle weights to zero over time. Instead of zeroing puppetMaster.muscleWeight and pinWeight, you can do that for each muscle independently using muscle.props.pinWeight and muscle.props.muscleWeight.
    You can use muscle.props.Group enum to define the weight reducing speed for each muscle group.

    Best,
    Pärtel
     
  4. alexkarak

    alexkarak

    Joined:
    Feb 7, 2018
    Posts:
    7
    Thank you so much! so simple and still couldnt think of it! It works perfect
     
  5. jfonz001

    jfonz001

    Joined:
    Jul 19, 2017
    Posts:
    12
    Hey Partel,

    Do you have any tips for adjusting individual muscle settings?

    I’d like to have my puppets display injuries, so if their arm is broken I want it to losely dangle.

    To do this I’ve been dropping pin and muscle weight on injured parts depending on severity of injury, but it only seems to impact things when set close to 0, and most of the time the part seems to follow the animation anyway depending on the part.
     
  6. alexkarak

    alexkarak

    Joined:
    Feb 7, 2018
    Posts:
    7
    Hey partel
    I read somewhere that puppetmaster and ice cc work well together...are there any videos or posts on how to set them up together?
     
  7. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,965
    Hey,

    You should use PuppetMaster.SetMuscleWeightsRecursive().
    Code (CSharp):
    1. public void SetMuscleWeightsRecursive(HumanBodyBones humanBodyBone, float muscleWeight, float pinWeight = 1f, float mappingWeight = 1f, float muscleDamper = 1f) {
    For example if you wish to injure the right arm, you should call that with HumanBodyBones.RightUpperArm.
    If the "injury" is not enough, just lower the weights, the pinWeight should probably be 0. If you increase muscleDamper value, the arm will become more lazy.

    Hey,
    Sorry, I have no idea about "ice cc", never heard of it actually.

    Best,
    Pärtel
     
  8. strich

    strich

    Joined:
    Aug 14, 2012
    Posts:
    283
    Is there an example of PuppetMaster + FinalIK with the supplied `CharacterPuppet` controller? I know there is a small set of demoes in the integration folder, but none involve a player controller.

    I've managed to set it all up, but it appears to me there is a problem in ordering of the IK / Physics, as I am getting teleporting animation transitions, like so:


    It seems like the character controller isn't moving as far as the ragdoll. So when it blends back, to snaps to the position of the controller.
     
    Last edited: Nov 10, 2019
  9. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,965
    Hey,
    What kind of IK were you using/need to use on that CharacterPuppet controller? Normally it should just work as expected if you add on the IK. About your screen capture, that kind of a bug usually happens when a character controller does not adapt to the new position of the puppet provided by BehaviourPuppet when it starts to get up. The character controller must be disabled while the puppet is unpinned and when it gets up from wherever it landed, the character controller must accept the new position of the character and go on from there.

    Best,
    Pärtel
     
    strich likes this.
  10. strich

    strich

    Joined:
    Aug 14, 2012
    Posts:
    283
    Cheers Partel, I fixed it -> Puppet Master had the wrong Target Root transform.

    I've got Full Body IK and Interaction System components on this character as well, so I can physically push buttons, etc. That's fine right?
     
  11. FiveFingerStudios

    FiveFingerStudios

    Joined:
    Apr 22, 2016
    Posts:
    369
    Is it possible to keep the puppetmaster hierarchy separate from the character or does it have to be parented with the character?
     
    Last edited: Nov 26, 2019
  12. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,965
    Hey,
    Yes, it should be fine. I haven't even tried that actually myself, but can't think of a problem.

    Hey,
    It is possible. You can decouple them after you have set up the puppet. Networked rigs usually require network components to be on the root of the character and if you have Rigidbody syncing on that, it will be a problem for PM, because the ragdoll needs to be actuated by physical forces only. To solve that, you can rearrange the prefab like this:
    Network Dummy.JPG

    Then call puppetMaster.transform.root = null; after the prefab has been instantiated to make sure PuppetMaster transform is not messed with.

    Cheers,
    Pärtel
     
  13. pravusjif

    pravusjif

    Joined:
    Jul 24, 2012
    Posts:
    13
    Hi Partel



    How can I make the behaviour be initiated by the PuppetMaster? recently I updated the plugin in my project and suddenly this reference is always null.
     
  14. jfonz001

    jfonz001

    Joined:
    Jul 19, 2017
    Posts:
    12
    Hi Partel thanks for all the help so far.

    I noticed when my puppet swings a weapon during melee attacks, the collider sort of slides off and is out of sync with the mesh/object during the swing. I see this happening in both my own game and the Melee demo, and with both Unmapped and Active puppets. Is there a way to fix this? (the screenshot below is an Active puppet)

    upload_2019-11-20_17-56-30.png

    Thank you
     
  15. Tmtakala

    Tmtakala

    Joined:
    Mar 12, 2014
    Posts:
    11
    Has anyone tried the new Havok physics with PuppetMaster? Does it make a difference in terms of simulation stability and accuracy?
    https://blogs.unity3d.com/2019/11/06/havok-physics-in-unity/

    Apparently krehzzzy on this same thread (page 32) had gotten more stable results with the new joint solver in Unity 2019.3, but Partel didn't notice much difference and recommended using the old solver (because it is faster) unless there are stability issues. I found this interesting.
     
  16. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,965
    Hey,
    By always did you mean you tried to check it in Update too? If not, I think it's just that you are using behaviour.puppetMaster in Awake before PM has initiated so please try switching to Start.

    Hey,
    I don't see that happening here, so I'm guessing maybe you have changed fixed delta time in that project to a larger value so PhysX has trouble solving those joints accurately enough.

    Hey,
    Havok is on my roadmap, but it's likely gonna take a major rewrite to make it work, rather than just a quick try.
    Hopefully Havok will be more similar to Unity Physics and it's not gonna be 2 major rewrites :)

    Cheers,
    Pärtel
     
  17. jfonz001

    jfonz001

    Joined:
    Jul 19, 2017
    Posts:
    12
    Thanks for the response, unfortunately it looks like my fixed delta time is still set to the default of 0.02

    upload_2019-11-25_19-46-59.png

    Do you have any other ideas as to what might be causing this? I'm having trouble finding similar issues/answers on google.

    Thanks again.
     
  18. gliealonso

    gliealonso

    Joined:
    Oct 21, 2018
    Posts:
    15
    Hi Partel.

    I was looking at this post, but I quite couldn't understand it. Could you please give me an example on how to, let's say, disable the body and upper chest of a puppet?

    Many thanks,
    Gabriel.
     
  19. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,965
    Hey,
    Could you please create a new project and see if it looks the same there? Would help isolating the problem.

    Hey,
    So if you try adding this script to the puppet in the "Puppet" demo:

    Code (CSharp):
    1. using UnityEngine;
    2. using RootMotion.Dynamics;
    3.  
    4. public class SetMuscleWeightTest : MonoBehaviour {
    5.  
    6.     public PuppetMaster puppetMaster;
    7.    
    8.     void Update () {
    9.         if (Input.GetKeyDown(KeyCode.A))
    10.         {
    11.             puppetMaster.SetMuscleWeightsRecursive(HumanBodyBones.LeftUpperArm, 0.01f, 0f);
    12.         }
    13.     }
    14. }
    That would make the whole left arm just dangle after you press A. That is because we're setting muscle weight to a very low value to make the arm muscles very weak, also setting pin weight to 0 to disable the world space AddForce pinning to animation for the arm.
    If you use HumanBodyBones.Spine, it would have the same effect on the whole upper body.

    Best,
    Pärtel
     
  20. jfonz001

    jfonz001

    Joined:
    Jul 19, 2017
    Posts:
    12
    OK made a new project and just imported puppetmaster...good call, the collider slides off maybe a little bit but not nearly to the extent as it does in my project.

    From the fresh project:
    upload_2019-11-29_18-3-46.png

    I wish I knew more about how it all worked so that i can offer up some clues, but I'm at a loss here so any help is much appreciated!
     
  21. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,965
    OK, could be a number of things, probably something in the Physics Settings like a lower "Default Solver Iterations". Maybe make a screenshot of the default PhysicsManager and then compare it to your project.
     
  22. joebain

    joebain

    Joined:
    Oct 24, 2014
    Posts:
    38
    Hi, I'm trying to create an explosion effect, so my puppet will be sent up in the air with some force, while playing a flailing animation, which fades into a ragdoll. I'm slightly tearing my hair out though because the character is stuck in place, they respond to the force, but don't go flying. I have tried setting the muscle pin weights to 0 which from what I've read ought to allow the physics to take over and send my character into the air, but it seems to have no effect.

    PuppetMaster.SetMuscleWeightsRecursive(0, 1, 0);


    If I increase the explosion force they will go flying but they go way too far, it seems like in this case PM is allowing the puppet to "break" free and gives up control or something? The docs are not that helpful when it comes to understanding some of the core concepts unfortunately.

    Thanks!

    Edit: It seems that if I don't call
    PuppetMaster.Kill()
    then the ragdoll behaves as I want. I wonder why this is causing a problem?
     
    Last edited: Dec 2, 2019
  23. jfonz001

    jfonz001

    Joined:
    Jul 19, 2017
    Posts:
    12
    Hey,

    Turns out the Physics Settings are identical except for the layer matrix. I set the Default Solver Iterations to the max (255) and the problem still remains.

    Another clue, it seems to get worse on collision with another ragdoll object, see the screenshot below:

    upload_2019-12-2_20-12-26.png

    Contrast this with the following screenshot from my test project, solver iterations set to 6:

    upload_2019-12-2_20-14-43.png

    As you can see there's still some sliding but this is more of an acceptable level in my opinion.

    Other than the solver iterations, is there anything else I should take a look at?

    Thanks
     
  24. cfusion

    cfusion

    Joined:
    Jul 18, 2011
    Posts:
    8
    Were you able to fix the issue with the Ragdoll Editor? I'm having the same issue using Unity 2019.2.10.
     
  25. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    554
    Hi, Partel, the lastest Puppet Master "Disconnecting Muscles" example has some bugs.
    The skeleton falls down immediately after starting. This is verified in 2019.2.14f1
    Thanks.
    upload_2019-12-3_14-35-28.png
     
  26. gliealonso

    gliealonso

    Joined:
    Oct 21, 2018
    Posts:
    15
    I did! But I don't remember what I did to fix it. I think I started the puppetmaster setup from the very beggining.

    EDIT: I think I remember how I did it. It could be possible that the bones on your Full Body Biped IK might be without references
     
    Last edited: Dec 3, 2019 at 11:30 PM
  27. SSSekhon

    SSSekhon

    Joined:
    Jun 3, 2016
    Posts:
    6
    Amazing product Partel, probably one of the best assets (along with Final IK) available.

    A few question if I may please.

    So I'm developing a fighting engine/boxing game that has the mechanics pretty are far along. Currently I cause knockdown when either health drops to 0% or an attack causes a knock down based on an algorithm that factors in attack power, fatigue, durability etc and then fell switch the puppet master to the correct state. In this way I can use the behaviourPuppet and follow how you have outlined things.

    However what I would prefer to do is go to ragdoll for falling down so we get alot more randomness but then switch to behaviourPuppet for getting back up.

    How would one go about this in the correct manner as I get many bugs and adverse effects with my current tests.

    Thank you.
     
  28. jfonz001

    jfonz001

    Joined:
    Jul 19, 2017
    Posts:
    12
    Hey are you using the fall and get up States from PuppetBehavior? Check out Third Person Puppet gameobject on the Melee demo.

    I’m also working on a melee combat system. Basically I have a script in each puppet master collider that checks for a “critical” hit, and if one occurs I drop the pin weight/muscle strength and set “can get up” to false in the PuppetBehavior script. I then play a animation depending on the type of damage received while the puppet is downed. After a certain amount of time I restore the pin weight and muscle and cangetup back to true, and PuppetBehavior will automatically do its thing and play whatever GetUp animation you put in the state.

    Sorry I’m on mobile and definitely have some of the variable and script names wrong, but check out melee demo that should cover it. You need the PuppetBehavior script and the corrosponding mechanim states.
     
    Partel-Lang likes this.
  29. SSSekhon

    SSSekhon

    Joined:
    Jun 3, 2016
    Posts:
    6
    Hey, thanks for your help.

    Yes that is how I currently do it but would like to go to more of a ragdoll approach and then blend to an animated get up.

    I also set the can get up variable to false and start a timer (0-10 for boxing knockdown) and randomly set can get up to true if my puppet can get up.

    I'm also typing of mobile so want to keep this reply brief but will hopefully go more in depth to explain what I'm doing and want to achieve.
     
  30. gliealonso

    gliealonso

    Joined:
    Oct 21, 2018
    Posts:
    15

    Hey man,

    So what I did was, I created Unity Event and invoked it when the character dropped below 0% health, and the Event was "Kill" from puppet master, like the example below(did the image upload correctly?):


    If you want the character to get up afterwards, you just gotta use another Event called "Resurrect"(For the getting up animation, you gotta use the "Puppet (with Fall) and Fall" animations like the example from this video:
    )

    Let me know if you have any questions.
    Gabriel.
     

    Attached Files:

    Partel-Lang likes this.
  31. SSSekhon

    SSSekhon

    Joined:
    Jun 3, 2016
    Posts:
    6
    Brilliant, thank you. I will try this when I'm next playing around with it.
     
    gliealonso likes this.
  32. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,965
    Hey,
    Just make sure to call
    Code (CSharp):
    1. behaviourPuppet.SetState(BehaviourPuppet.State.Unpinned);
    before you add explosion force to the ragdoll. Otherwise the pinning forces that keep the puppet pinned to the animation will neutralize your explosion forces (unless they are big enough to make the ragdoll parts exceed BehaviourPuppet's knockOutDistance).

    That's very odd, have not seen it before. Which Unity version are you using? Maybe something related to that. Maybe you could zip that project (even if it's just PM) and send a link over via PM?

    Hey,
    Which Unity version were you using and which PuppetMaster version (can check that from Plugins/RootMotion/PuppetMaster/PuppetMaster ReadMe)?

    Hey,
    Just loaded up v0.9 in 2019.2.14f1, but did not see it. Did you try in a new empty project? Perhaps your project has Layer Collision Matrix changed from the default, that usually is the cause of demo scenes failing.

    Hey and thanks!

    Basically, if you used the "Puppet" prefab from the package, just drop it under "Behaviours" gameobject in the puppet hierarchy. Then select the "Humanoid Third Person Puppet" animator controller and copy the "BehaviourPuppet" and "BehaviourFall" sub-state machines over to the animator controller that you are using. Make a transition from the "BehaviourPuppet" sub-state machine to you idle animation state, just like in the "Humanoid Third Person Puppet" controller. That should get the losing balance and getting up system going.

    If you have melee attacks, it's good to use Boosters to give the attacks more punch. Declare a public Booster booster; in your AI script and fill it out in the editor. When an attack starts, call booster.Boost(behaviourPuppet) to give the attacking puppet some temporary immunity and/or impulse multiplication. The boost effect falls off over time, defined by "Boost Falloff" in BehaviourPuppet. Value of 1 means the effect will be gone in 1 second.

    Tweak the "Collision Resistance" and "Knock Out Distance" values in BehaviourPuppet to define how much impact damages the pinning and how far the muscles can drift from their targets before the puppet is unpinned.

    To handle the health and dying, you can use the BehaviourPuppet.OnCollisionImpulse(MuscleCollision m, float impulse) delegate or BehaviourPuppet.OnCollision(MuscleCollision m) delegate. The former is called only for collisions that damage the pinning forces, the latter is called for every collision.

    Code (CSharp):
    1. public BehaviourPuppet puppet;
    2.  
    3. void Start() {
    4. puppet.OnCollisionImpulse += OnCollisionImpulse;
    5. }
    6.  
    7. private void OnCollisionImpulse(MuscleCollision m, float impulse) {
    8. health -= impulse;
    9. if (health <= 0f) {
    10. puppet.puppetMaster.Kill();
    11. }
    12. }
    Cheers,
    Pärtel
     
  33. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    554
    Oh, I see. I loaded into the fresh project but I'll double-check. Thanks.
     
  34. SSSekhon

    SSSekhon

    Joined:
    Jun 3, 2016
    Posts:
    6
    @Partel-Lang Hi thanks, I was doing most of that originally but now use animancer so have my on fsm that handles animations.

    OnCollisionImpulses looks like it will be helpful although I have a custom damage system in place that uses a robust system to access data and act upon the results giving me great results.

    I will hopefully ask more questions soon and really appreciate the responses.

    I'm not sure if you've ever seen fight night champion but I'm playing around looking to get results similar to that where arms slide over body parts when impact is glancing.

    Thanks
    Surinder