Search Unity

PuppetMaster - Advanced Character Physics Tool [RELEASED]

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

  1. jfonz001

    jfonz001

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

    Do you have any guides on manually adding extra limbs (like a tail on a wolf)? I have manually added a tail to my wolf complete with all of the rigidbodies and joints and everything. It's all nested in the same way as the armature, but the tail colliders are not following the animation/mesh (the tail swaying side to side). They remain with the rest of the puppet and follow it around but stay static.

    Thank you
     

    Attached Files:

    Last edited: Dec 30, 2019
  2. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    704
    Hi, Partel,

    In PuppetMaster component, when I set the Props Group to "Foot" in "Individual Muscle Setting", it disables the collider.

    I think the reason why you disable is so that the puppet can walk on the surface without collision but it's causing other problems.

    I use the Puppet collider for bullet-hit tests on the bodyparts but it won't work on Feets.

    My questions are

    1. Where does it disable the collider in the code? I could not easily find it.

    2. Let say we don't disable the Foot colliders, will the Puppet walk normally as before? I think we need to take care of Feet as a special case so that Puppet can walk without affecting the balance. Without the special treatment, the feet colliders often penetrates the ground and it will cause some problems. I think you just disabled the collider but that affects other collision tests. I think PuppetMaster should just remove the Feet from the collision internally.

    Thanks.


    upload_2019-12-30_22-39-21.png
     
  3. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hey,
    It would require a recursive check and for example for the hand muscle that would have to go 5 steps up the hierarchy so I don't think it would be any faster than a GetComponent call really. Remember the code can run hundreds of times a frame. I wish Unity used a bitmask not just strings for the gameobject tags.

    Hey,
    Something like this:
    Code (CSharp):
    1. hitReaction.Hit(collision.collider, -collision.GetContact(0).normal * collision.impulse.magnitude, collision.GetContact(0).point)'
    But if it's something like VR combat, PuppetMaster can handle that a lot better, there is a boxing demo included, looks like this.

    Hey,
    Could it be that when you set up the puppet in Update, the character has already animated. In that case the ragdoll prefab's pose does not match up with the character pose anymore. The pose must be the same as default because when ragdolls are activated by Unity the joint default rotations will be set to whatever the rotations of the bones and if they are random, joint limits will not behave as you'd expect anymore. That's why puppets must be set up right after you instantiate the character, because animation or anything like that can change the pose. If you wish to instantiate and set up puppets from Update, instantiate the character as well as the ragdoll prefab from the same place like this:

    Code (CSharp):
    1. [Tooltip("Character prefab to instantiate (without ragdoll)")]
    2.     public Transform characterPrefab;
    3.  
    4.     [Tooltip("Creating a Puppet from a ragdoll character prefab.")]
    5.     public Transform ragdollPrefab;
    6.  
    7.     [Tooltip("What will the Puppet be named?")]
    8.     public string instanceName = "My Character";
    9.  
    10.     [Tooltip("The layer to assign the character controller to. Collisions between this layer and the 'Ragdoll Layer' will be ignored, or else the ragdoll would collide with the character controller.")]
    11.     public int characterControllerLayer;
    12.  
    13.     [Tooltip("The layer to assign the PuppetMaster and all it's muscles to. Collisions between this layer and the 'Character Controller Layer' will be ignored, or else the ragdoll would collide with the character controller.")]
    14.     public int ragdollLayer;
    15.  
    16.     void Start()
    17.     {
    18.         Transform target = Instantiate(characterPrefab, transform.position, transform.rotation);
    19.         target.name = instanceName;
    20.  
    21.         Transform ragdoll = Instantiate(ragdollPrefab, transform.position, transform.rotation);
    22.        
    23.         PuppetMaster.SetUp(target, ragdoll, characterControllerLayer, ragdollLayer);
    24.     }
    Hey,
    You'll also have to manually add the tail joints to the "Muscles" array on the bottom of PuppetMaster. Just expand the array, increase it's size by the number of tail musles you have and assign the tail joints and target transforms. Don't forget to set Group to "Tail" under the "Props" too.

    Hey,
    If you go to the "Foot" group override under BehaviourPuppet's "Muscle Group Properties" header, you'll probably see "Disable Colliders" enabled, that's what does it. That keeps the foot colliders disabled while in Puppet state, they will be enabled only in Unpinned state. You can disable that to have the colliders enabled at all times, but you'll probably get issues with feet getting stuck behind ground colliders. Foot placement correction like the Grounder of Final IK can help somewhat with that. Could also have the feet colliders on a layer that ignores ground collisions while behaviourPuppet.state != BehaviourPuppet.State.Unpinned.

    Cheers,
    Pärtel
     
  4. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    704
    I see. I missed it because the group name is just an integer. Thanks for the tip and it works.

    Having Puppet to walk on a ground smoothly was very difficult to control and I gave up on using PuppetMaster before, but I need it again for hit-reaction and other stuff. I hope it works better this time. ^^

    FYI, I think it's better you assume ground layer and other collidable objects have "Default" layer instead of assuming some special layer, like "Water"
    I think "Default" is what everyone is using and it wasn't easy to set it up out of the box.

    Thanks.
     
    Hobodi likes this.
  5. jfonz001

    jfonz001

    Joined:
    Jul 19, 2017
    Posts:
    18
    UPDATE: Woo! Got it right after I posted this. In the screenshot below I placed the transforms for the PuppetMaster upper and lower tail gameobjects. I didn't know I was supposed to use the Armature's transforms. Swapped those out and we're in business, thanks!

    For future people looking to create a tail or other additional limbs, here are the steps I followed to create my wolf:

    1. Use the Bi-Ped Ragdoll creator to create your character (ignoring the tail/additional limbs for now)
    2. In the PuppetMaster 'root' GameObject that is created after the set up of the puppet I created two additional GameObjects for my Upper and Lower tail bones. These are named and nested exactly the same as they are in my armature.
    3. I copied the Rigidbody, joint and Collider from another limb that PuppetMaster already set up for me. You may need to adjust the values on each of these components but I just left them alone for now as they were close enough to get me through this step.
    4. Go to the PuppetMaster component and add your bones to the Muscles array at the bottom. Use the Joints from your new PM objects that you created. The 'Target' transforms come from the original armature that these joints need to follow.
    --------------Ignore below, figured it out thank you-------------
    Hey Partel thanks, I should have mentioned though that I have that set up already. I'll continue poking around but if you have any other ideas let me know, thanks!

    upload_2019-12-31_12-23-55.png
     
    Last edited: Dec 31, 2019
    gliealonso likes this.
  6. gliealonso

    gliealonso

    Joined:
    Oct 21, 2018
    Posts:
    117

    Hi Partel,

    That VR Combat demo looks great! I couldn't find the demo though. There is one called boxing, but it doesn't have the puppetmaster setup. I did try using the normal puppetmaster as a hit reaction, however the opponents looked like they had springs on them and they were shaking making it look unrealistic, I tried setting up the muscle damper and spring, but I couldn't find a good setup. What is the name of that demo?

    Thanks and Happy 2020!
    Gabriel.
     
  7. jason416

    jason416

    Joined:
    Nov 8, 2018
    Posts:
    31
    Hi I'm a bit stuck in the weeds on something, I'm using Puppermaster with FinalIK (FBBIK) and I'm using the PropMuscle system. The same prop can be held with one hand or both hands.

    I had been using the propMuscle on the Right hand and using a Left-Hand-Effector in FBBIK to optionally grip with both hands. But I think this is a circular reference right? and I think it's causing flyaway issues when the puppet dies.

    What is the right way to set up two hands with puppet master?

    EDIT: I managed to solve the flyaway problem, looking closer at the demo scene I found that the prop M4 was set to ignore internal collision on every muscle group, so doing that solved the flyaway. But I'm still curious about having the left hand targeting the prop which is itself puppeted... is this a bad idea?
     
    Last edited: Jan 2, 2020
  8. lazyricer

    lazyricer

    Joined:
    Jan 1, 2020
    Posts:
    1
    When my character is free falling, the ragdoll starts to lag behind slowly and gets further and further away from the character and eventually gets unpinned. Is this supposed to be the intended behaviour? I'm not using any puppet behaviours.
     
  9. jfonz001

    jfonz001

    Joined:
    Jul 19, 2017
    Posts:
    18
    I think you need to at least use the standard "puppet" behavior
     
  10. gliealonso

    gliealonso

    Joined:
    Oct 21, 2018
    Posts:
    117
    Hi!

    I don't have my Unity open, but I remember that there is a demo scene called "second hand", or "aiming", and there is a tool that will let the left hand target a transform of your choosing, that is what I did for my character to wield a double handed sword. If that doesn't work, let me know, then I will open my Unity and check the details.
     
  11. alexkarak

    alexkarak

    Joined:
    Feb 7, 2018
    Posts:
    28
    Hey Partel again same thing happens! My clone is created ...all good...but it doesnt have any behaviours(fall and puppet) in it as the original has ,.... so it doesnt fall or react as a puppet!
     
  12. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hey guys, sorry for the wait and happy new year!!

    Hey,
    Problem is, most games have most of the stuff on Default layer, and the PuppetMaster needs the ground and other stuff to be separated, I guess I should make a tutorial or manual page about layer setup, thanks!

    Hey,
    The package is "VR Boxing (Oculus, Unity 5.6.5)" and it will import the "PuppetMaster/_DEMOS/VR" folder that includes the "PuppetMaster VR Boxing (Oculus)" demo scene, that should have the PuppetMaster setup in it. That scene also requires you to have Oculus utilities imported into the project. That folder also includes the VRPuppet.cs script, that is a little add-on script you should add to PuppetMaster to get rid of the rubber chicken effect. This is how it is set up in the demo:

    VRPuppet.PNG

    Hey,
    Please import the Final IK integration package from Plugins/RootMotion/PuppetMaster/_Integration. Check out the "Ragdoll Aiming" demo, play the scene and set Pin Weight to 0 in PuppetMaster. The left hand is maintained on the weapon by solving a LimbIK component after PuppetMaster writes, using PuppetMaster.OnWrite delegate. The script is RagdollAiming.cs, you can find it on the Dummy.

    Hey,
    Did you mean you were not using BehaviourPuppet? If so I can't understand how it could unpin as BehaviourPuppet is the thing that unpins the puppets. Any steps I could take to reproduce the issue or maybe you can send me a repro?

    Hey,
    You'll need to instantiate the behaviours. Store the original behaviours as prefabs and instantiate them right after you instantiate or setup the puppets, you can parent them to PuppetMaster or the "Behaviours" gameobject.

    Cheers,
    Pärtel
     
    hopeful likes this.
  13. gliealonso

    gliealonso

    Joined:
    Oct 21, 2018
    Posts:
    117
    Hi Partel!

    Could you please send me the VR Puppet script to remove the rubber chicken (I love this description hahaha) effect?

    I tried downloading Oculus utilities and then opening the VR Boxing Oculus pack, but it doesn't work.

    Many thanks!
    Gabriel.
     
  14. ColtonKadlecik_VitruviusVR

    ColtonKadlecik_VitruviusVR

    Joined:
    Nov 27, 2015
    Posts:
    197
    Hey Partel,
    Starting a new character setup with VRIK and Puppet Master and getting good results. I changed the hierarchy of my puppet master bodies (to match yours from an example I found) and have now messed up the legs. All joints in the leg seem to snap to the pelvis (something to do with map position). How can I fix this? Also, I have been reading up on joints, should all rigid bodies enable pre processing or no?
    Cheers,
    Colton

    EDIT: Got the issue with the legs fixed. Still curious about the pre processing thing though. Also, is there anyway for the hands to follow the colliders over the VRIK when close to objects. I can still sometimes push the characters hand into geometry but when I look in the scene view the colliders are in the correct place outside. Dynamically adjust pin weight?
     

    Attached Files:

    Last edited: Jan 8, 2020
  15. ColtonKadlecik_VitruviusVR

    ColtonKadlecik_VitruviusVR

    Joined:
    Nov 27, 2015
    Posts:
    197
    Here's that file

    Cheers,
    Colton
     

    Attached Files:

    gliealonso likes this.
  16. gliealonso

    gliealonso

    Joined:
    Oct 21, 2018
    Posts:
    117
    Thanks, bro!
     
  17. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hey,
    Maybe try importing to a new project, your existing one might probably has layer setup and stuff changed. Also make sure you have the latest version.
    If still doesn't work, I see you already got the script (thanks ColtonK!), this is how it is set up in the demo:
    VRPuppet.PNG

    Hey,
    Joint preprocessing only matters if your rigidbodies have some of their rotational degrees of freedom frozed (under Rigiodbody constraints), which you probably don't have, so you can keep that disabled.

    To fix the hands going through colliders, probably need to enable "Map Position" for all the Muscles, expand the Muscles array on the bottom of PuppetMaster and you'll find it under each muscle's "Props". Muscles that don't have that enabled are mapped to ragdoll only by rotation so the positional error can come from that. It is an optimization.

    Cheers,
    Pärtel
     
    gliealonso likes this.
  18. nmbileg

    nmbileg

    Joined:
    Sep 29, 2017
    Posts:
    23
    Hello Partel, I just bought your asset and it's amazing! I'm so new to this asset so my question might very fundamental.
    I think my 3d character isn't completely attached to the puppet master, when the colliders seperate from the animations the result is looking like this:
     

    Attached Files:

  19. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    @Partel-Lang
    Hey quick question - is it possible to run the IK solver in editor from code?

    Do you just manually call update?

    (Sorry to clarify this is a FinalIK question not puppetmaster)
     
    Last edited: Jan 13, 2020
  20. Tmtakala

    Tmtakala

    Joined:
    Mar 12, 2014
    Posts:
    16
    Hi,

    I added finger muscles to my Puppet by expanding the Muscle array size. What is the proper way to remove muscles in the Editor if I want to get rid of the Finger muscles?

    I tried downsizing the Muscle array size back to original, but that made the hand behave differently (it was more sluggish to turn, almost like the finger rigidbodies were now weighing it down).

    There is also the option to "Delete Array Element" if I right click on each array element. I do not know if this removes the finger muscles properly, i.e. returning the hand muscle behavior to exactly like it was before adding the finger muscles. At least this doesn't remove the ConfigurableJoint, Rigidbody, and Collider from the PuppetMaster rig. I suppose I need to remove this manually..?
     
  21. gliealonso

    gliealonso

    Joined:
    Oct 21, 2018
    Posts:
    117
    Hey there,

    When this happens to me, it's always because something is wrong with the setup, I would suggest starting over and trying again.
     
  22. gliealonso

    gliealonso

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

    I have been trying to understand how to use this code, I'm confused to what hitReaction is.

    I have tried setting hitReaction as multiple different components, but I can't find the correct one, could you please help me with that?

    Many thanks,
    Gabriel.
     
  23. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hey,
    That is an issue with the skinning of the model. Looks like there is a single vertex there that has no bone weights or weights assigned to a wrong bone so it gets left behind. Please check the skinning in the 3d app you used for creating the model.

    Hey,
    Yes, please add the EditorIK.cs component.

    Hey,
    Yes, just remove the array elements or downsize the array and also just delete the fingers from the PuppetMaster hierarchy.

    Hey,
    It's the HitReaction.cs component from Final IK. Please check out the "Hit Reaction" demo and HitReactionTrigger.cs.

    Cheers,
    Pärtel
     
  24. blogsabout

    blogsabout

    Joined:
    Aug 20, 2014
    Posts:
    50
    I'm playing with a concept with "rod dolls", those old vintage dolls with a stick up the back that can be moved and turned and the "ragdoll" will animate accordingly.
    Would Puppetmaster be the tool to make this? I have seen there is an IK target tool included and that could work for controlling the hands (then attack a stick to make it look like it's the stick that is moving the hand).
    Basically it's a "ragdool with a straight back, head up but arms and legs hanging.
     
    Last edited: Jan 17, 2020
  25. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hey,
    Yes, that sounds like something you could do pretty easily with PuppetMaster. You could drive the hands with IK or attach joints to pull them. PuppetMaster will also allow you to play animation via muscles.

    Best,
    Pärtel
     
  26. Scarabay

    Scarabay

    Joined:
    Sep 7, 2013
    Posts:
    19
    Partel-Lang, how to instantly apply saved position\rotation\force to rigidbodies of my AI agent with PuppetMaster component? I work on a save system for my game and want to restore agent's "dead" state.
     
  27. Toylips

    Toylips

    Joined:
    Feb 15, 2013
    Posts:
    28
    @Partel-Lang
    Hey! Thanks for the cool Puppet!

    Have some question for you, I'm trying to pin some puppets and drop them out the ship.

    but I have some strange blink effect on the target root when it's going to the dead state.

    the vid

    I think this breaks my unpin stage, because it plays OnLoseBalance animation after going to alive state.

    I'm using only puppet behavior.

    What should I do for not losing the balance when going out the ship ?
    And how to avoid target root blink when changing states?


    fullVid

    Code (CSharp):
    1.         public void Grab()
    2.         {
    3.             targetUnit = PuppetPoolsManager.s_Instance.GetActivated;
    4.             targetUnit.PuppetMaster.Teleport(spawnPoint.position, spawnPoint.rotation, true);
    5.             targetUnit.PuppetMaster.OnTeleported += PinToHead;
    6.             targetUnit.Agent.Enable = false;
    7.             targetUnit.PuppetMaster.solverIterationCount *= solverIterationMlp;
    8.  
    9.             targetUnit.PuppetMaster.state = State.Dead;
    10.         }
    11.  
    12.         public void Release()
    13.         {
    14.             targetUnit.PuppetMaster.solverIterationCount /= solverIterationMlp;
    15.             createdJointFroGrabbingOn.connectedBody = null;
    16.             targetUnit.PuppetAliveState();
    17.             targetUnit.PuppetMaster.OnTeleported += UnPin;
    18.             targetUnit.PuppetMaster.Teleport(spawnPoint.position, spawnPoint.rotation, true);
    19.  
    20.  
    21.  
    22.         }
    23.  
    24.         void UnPin()
    25.         {
    26.             targetUnit.m_rigidbody.velocity = Vector3.zero;
    27.             targetUnit.m_rigidbody.useGravity = true;
    28.             targetUnit.Anim.animator.enabled = true;
    29.             targetUnit.Anim.PlaySpawnState();
    30.         }
    31.  
    32.    
    33.  
    34.         void PinToHead()
    35.         {
    36.  
    37.             createdJointFroGrabbingOn.autoConfigureConnectedAnchor = true;
    38.  
    39.             var puppetParts = targetUnit.PuppetMaster.transform.GetAllTransforms().ToArray();
    40.  
    41.             for (int j = 0; j < puppetParts.Length; j++)
    42.             {
    43.                 if (puppetParts[j].name.Contains(grabbedPart.ToString()))
    44.                 {
    45.                     targetGrabbedPart = puppetParts[j].GetComponent<ConfigurableJoint>();
    46.                     break;
    47.                 }
    48.             }
    49.  
    50.             createdJointFroGrabbingOn.connectedBody = targetGrabbedPart.GetComponent<Rigidbody>();
    51.  
    52.             targetUnit.m_rigidbody.useGravity = false;
    53.  
    54.             targetUnit.PuppetMaster.OnTeleported = null;
    55.  
    56.  
    57.         }
     
    Last edited: Jan 19, 2020
  28. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    338
    Does this still work, or have both products evolved too much since 2015?
     
  29. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hey,
    I think you'd just need to foreach puppetMaster.muscles and store all positions and rotations of each muscle.rigidbody and write that data to the save file. When you load, just do the inverse of that.

    Hey,
    That video resolution was pretty bad so difficult to see.
    Why are you calling PuppetMaster.Teleport() when you release the puppets? I think you should just get rid of the createdJointForGrabbingOn and let it fall. I'd take a look at your project or a repo if you could send it over.

    Hey,
    Opsive's UCC/TPC version 2.0 and later are not currently supported. I'm still exchanging mails with Opsive about this, we've been trying to fix it for a long time but sometimes I have a lot of other priorities to deal with and some other times they do, but I'm still hopeful.

    Best,
    Pärtel
     
    nobluff67 likes this.
  30. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    338
    Hi Partel,

    Ultra frustrated here, I'm sure you can help calm me down.

    I have spend hours perfecting the look (tweaking colliders, setting up breakpoint by %, etc, etc), setting up behaviors. Everything works perfectly. I have now created a prefab of the character, which is an multi-spawn enemy (I think you know where I am going with this.)

    I have now realized (unfortunately after the fact), that instantiating the character multiple times as a prefab doesn't work correctly. So I have checked your demos and have found how you instantiate (separately). I have no issues with this. My issue is that I now have a completed character, so how do I reverse engineer my prefab, so that I can instantiate as per the puppetmaster way.

    My prefab is in the hierarchy of:

    Dummy
    --> Behavious
    --> PuppetMaster
    --> Dummy

    So from the hierarchy above:

    how do I duplicate this using your instantiates (ragdoll, puppets, behaviors)?

    EDIT:

    The issue I am running into when I instantiate the regular way, is that puppetmaster and puppet values are linked across all instances. eg I set pinweight in script to 0, all instances of the character are set to 0.

    I have checked the public variables for the puppetmaster and puppet, and they both point to their own instances. So I have no idea why this is happening.

    EDIT: EDIT:

    Might have found the issue, let me test and I will let you know if you can ignore the above.
     
    Last edited: Jan 26, 2020
  31. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    338
    EDIT: EDIT: EDIT:

    Found the issue. It was a script reference on one of my scripts. Seems like you can instantiate an entire character (including PM components) normally.
     
  32. eyalfx

    eyalfx

    Joined:
    Oct 8, 2010
    Posts:
    108
    Hi guys, We are looking to hire a Unity developer with FinalIK and PuppetMaster experience and Pärtel recommended that I'll post it in this thread.
    The ideal candidate will have a ton of experience with FBBIK, VRIK (Quest,Rift,Vive) and PuppetMaster as well as Unity RigidBodies, Soft Bodies and other physics related tasks.
    This is a paid job that can be done remotely (the team is based in LA). Please don't respond in this forum (we don't want to clutter it up) . Just email me directly at eyalfx@gmail.com .
    Thank you.
     
    Partel-Lang likes this.
  33. ChaosResolution

    ChaosResolution

    Joined:
    Jan 22, 2013
    Posts:
    80
    Hi @Partel-Lang! Are Puppetmaster and Final IK fully compatible with Unity 2019.3.0f6?

    Thanks!
     
  34. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hey,
    Yes, just double-checked to make sure. Also works with Unity 2020.
     
    MostHated and ChaosResolution like this.
  35. Redux

    Redux

    Joined:
    Nov 10, 2011
    Posts:
    146
    I have a generic rigged character which I tried to use with puppetmaster, and after setting everything up as I have done with my humanoid characters I saw this spam:


    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. RootMotion.Dynamics.Muscle.UpdateAnchor (System.Boolean supportTranslationAnimation) (at Assets/Plugins/RootMotion/PuppetMaster/Scripts/Muscle.cs:909)
    3. RootMotion.Dynamics.PuppetMaster.Read () (at Assets/Plugins/RootMotion/PuppetMaster/Scripts/PuppetMaster.cs:1320)
    4. RootMotion.Dynamics.PuppetMaster.OnLateUpdate () (at Assets/Plugins/RootMotion/PuppetMaster/Scripts/PuppetMaster.cs:1114)
    5. RootMotion.Dynamics.PuppetMaster.LateUpdate () (at Assets/Plugins/RootMotion/PuppetMaster/Scripts/PuppetMaster.cs:1074)
    6.  
    I checked the puppetmaster component and everything appears set properly, no missing references on any of the muscles or anything.
     
  36. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hey,
    It must be that one of the muscles has it's Joint missing. Please expand the "Muscles" array on the bottom of PM and make sure all muscles have their joint field assigned.

    Best,
    Pärtel
     
  37. Redux

    Redux

    Joined:
    Nov 10, 2011
    Posts:
    146
    Will take a look.
     
  38. Redux

    Redux

    Joined:
    Nov 10, 2011
    Posts:
    146
    I have double checked and that's not the case. The joints are set in every muscle definition.

    [Edit]
    It appears it's the pelvis which has no connected rigidbody. What might I have done wrong to instigate this in earlier stages of setup?

    [Edit 2]
    I believe I found the problem. During ragdoll setup, I had the root reference set to the wrong thing in the Biped Ragdoll Creator
     
    Last edited: Feb 6, 2020
  39. ColtonKadlecik_VitruviusVR

    ColtonKadlecik_VitruviusVR

    Joined:
    Nov 27, 2015
    Posts:
    197
    Hey @Partel-Lang,
    I am following your example of combining VRIK, PM and locomotion. In this example, after adding force to the character controller in order to move the player via locomotion, you add the force to each muscle which makes sense. How should I handle the player collider being pushed by something (i.e. door)? Should each muscle follow the velocity of the character controller?
    Cheers,
    Colton
     
  40. Redux

    Redux

    Joined:
    Nov 10, 2011
    Posts:
    146
    @Partel-Lang So next question is about the puppetmaster setup procedure. I have colliders on my character pre puppetmaster which are intended for use outside of physics/puppetmaster and they are removed in the setup process. Is there a way to mark colliders so they will be ignored and left as is? If not I would suggest it as a feature addition to consider.

    [Edit]
    I added the following code to RemoveRagdollComponents() in PuppetmasterSetup.cs:

    Code (CSharp):
    1.                 if (colliders[i].tag == "Logic")
    2.                     continue;
    Code (CSharp):
    1.             // Get rid of (compound) colliders that are not used by Cloth
    2.             Collider[] colliders = target.GetComponentsInChildren<Collider>();
    3.          
    4.             for (int i = 0; i < colliders.Length; i++) {
    5.                 if (colliders[i].tag == "Logic")
    6.                     continue;
    7.                 if (colliders[i].transform != target && !IsClothCollider(colliders[i], cloths)) {
    8.                     DestroyImmediate(colliders[i]);
    9.                 }
    10.             }
    11.            
    And also RagdollCreator.cs in ClearTransform():
    Code (CSharp):
    1.             foreach (Collider collider in colliders) {
    2.                 if (collider.tag == "Logic")
    3.                     continue;
    4.                 if (collider != null && !collider.isTrigger) GameObject.DestroyImmediate(collider);
    5.             }
     
    Last edited: Feb 6, 2020
  41. b1gry4n

    b1gry4n

    Joined:
    Sep 11, 2013
    Posts:
    146
    Is there anything I can do for high speed puppet collisions causing the puppet to glitch around until they settle back into their "normal" state? The puppet is active at all times, I am using it for secondary air movement animations to get things like the legs and arms reacting to physics. The character is traveling at high speeds so when the character collides with an object sometimes this issue happens. I was thinking of doing a check to see if the muscle is too far away from its target, but I was wondering if theres something built in that could detect this or maybe the most ideal way to achieve this.
     
  42. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hey,
    Only thing I can think of is get the delta position (rigidbody.position - lastRigidbodyPosition) of the character controller in each FixedUpdate and add that as a VelocityChange force to every muscle. Other than that, can't think of a better way.

    Hey,
    You can set up PuppetMaster another way..
    Instead of using BipedRagdollCreator on the game character itself, drag a new instance of the model to the scene and set the ragdoll up on that instead. Then add PuppetMaster to that new ragdoll and assign the original character as "Target Root". Then click on "Set Up PuppetMaster". That way PM will not have to destroy any components and your colliders and other references will be fine.

    If you already set up the ragdoll and don't want to do it again, you can manually duplicate what you have and add PuppetMaster to the duplicate, assign the original as "Target Root".

    Hey,
    That is a general ragdoll stability issue, so please first check if there's anything from the joint stabitily guide that helps.
    Also, if you can update to Unity 2019.3, there's a new Temporal Gauss-Seidel solver type that you can switch to and it has much better joint stability.

    If still no luck, could check joint.currentForce.sqrMagnitude for some muscles and if that returns some insane values, do this:
    Code (CSharp):
    1. foreach (Muscle m in puppetMaster.Muscles) {
    2. m.MoveToTarget();
    3. m.ClearVelocities();
    4. }
    but only if behaviourPuppet.state == BehaviourPuppet.State.Pinned;

    Best,
    Pärtel
     
    b1gry4n likes this.
  43. Deckard_89

    Deckard_89

    Joined:
    Feb 4, 2016
    Posts:
    316
    Is there a way to exclude a certain bone from being affected by specific layers? For example, the hand bone my character uses to hold guns; if I collide with an enemy, his hand bone will go crazy as it constantly collides with the enemy's collider and the gun that is a child of it will therefore rapidly rotate with it - this is what I'm trying to stop, but I'm not sure how.
     
  44. gliealonso

    gliealonso

    Joined:
    Oct 21, 2018
    Posts:
    117

    I believe you can just select the collider from the hand and change the layer, no?
     

    Attached Files:

    Partel-Lang likes this.
  45. Deckard_89

    Deckard_89

    Joined:
    Feb 4, 2016
    Posts:
    316
    @gliealonso Oh right, thanks. I was under the impression that the Layer Setup script overrides the physics matrix.
    Thing is, I need the puppet to be affected by these layers, just not the hand bone. Are you "allowed" to have the hand bone on a separate layer to the rest of the puppet?
     
  46. alexkarak

    alexkarak

    Joined:
    Feb 7, 2018
    Posts:
    28
    Hey Partel ...I have a quick question...
    I have this script to instantiate a puppet in runtime....

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using RootMotion.Dynamics;
    4.  
    5. namespace RootMotion.Demos
    6. {
    7.  
    8.     // Code example for creating a Puppet in runtime.
    9.     public class CreatePuppetInRuntime : MonoBehaviour
    10.     {
    11.  
    12.         [Tooltip("Character prefab to instantiate (without ragdoll)")]
    13.         public Transform characterPrefab;
    14.  
    15.         [Tooltip("Creating a Puppet from a ragdoll character prefab.")]
    16.         public Transform ragdollPrefab;
    17.  
    18.         [Tooltip("What will the Puppet be named?")]
    19.         public string instanceName = "My Character";
    20.  
    21.         [Tooltip("The layer to assign the character controller to. Collisions between this layer and the 'Ragdoll Layer' will be ignored, or else the ragdoll would collide with the character controller.")]
    22.         public int characterControllerLayer;
    23.  
    24.         [Tooltip("The layer to assign the PuppetMaster and all it's muscles to. Collisions between this layer and the 'Character Controller Layer' will be ignored, or else the ragdoll would collide with the character controller.")]
    25.         public int ragdollLayer;
    26.         public Transform  Behaviours;
    27.         void Start()
    28.         {
    29.             Transform target = Instantiate(characterPrefab, transform.position, transform.rotation);
    30.             target.name = instanceName;
    31.  
    32.             Transform ragdoll = Instantiate(ragdollPrefab, transform.position, transform.rotation);
    33.  
    34.             PuppetMaster.SetUp(target, ragdoll, characterControllerLayer, ragdollLayer);
    35.  
    36.             Transform behaviours = Instantiate(Behaviours);
    37.                 behaviours.transform.SetParent(target.transform);
    38.         }
    39.     }
    40. }
    41.  

    BUT...how can i make the instantiated object a seperate gameobject ?? couse now it sares the same values with the original one!
     
  47. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hey,
    The LayerSetup script is only there to make PM demos work with new projects that have the default settings. You should get rid of that and use the Layer Collision Matrix to disable collisions between character controller and ragdoll layers. It's fine to have the hand on another layer.

    Hey,
    Sorry I did not understand, that script already instantiates new objects. Which values specifically were you referring to?

    Best,
    Pärtel
     
    Deckard_89 likes this.
  48. alexkarak

    alexkarak

    Joined:
    Feb 7, 2018
    Posts:
    28

    I have a behaviour designer heath variable and the instantiated object has the same "health" float as the original one! so when i hit one of the two objects (the original or the instantiated) it affects both! (they share the same health)


    I apply the damage with this script attatched to the Character controller of the puppet i want to instantiate! maybe this is the problem? i really dont know :/

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using RootMotion.Dynamics;
    5. using BehaviorDesigner.Runtime;
    6.  
    7. public class Cop : MonoBehaviour
    8. {
    9.     public BehaviourPuppet puppet;
    10.     public BehaviorTree behaviorTree;
    11.     public SharedFloat health;
    12.     public HealthBar healthbar;
    13.     void Start()
    14.     {
    15.        
    16.         puppet.OnCollisionImpulse += OnCollisionImpulse;
    17.         health = (SharedFloat)behaviorTree.GetVariable("health");
    18.         healthbar.SetMaxHealth(health);
    19.     }
    20.  
    21.     private void OnCollisionImpulse(MuscleCollision m, float impulse)
    22.     {
    23.  
    24.         health.Value -= impulse/100;
    25.         behaviorTree.SetVariableValue("health", health);
    26.         healthbar.SetHealth(health.Value);
    27.         if (health.Value <= 0f)
    28.  
    29.         {
    30.             behaviorTree.SetVariableValue("health", 0f);
    31.             puppet.puppetMaster.Kill();
    32.         }
    33.     }
    34.    
    35.    
    36.  
    37. }
    38.            
    39.    
     
  49. ColtonKadlecik_VitruviusVR

    ColtonKadlecik_VitruviusVR

    Joined:
    Nov 27, 2015
    Posts:
    197
    Thanks for the reply, this does work if the delta is divided by fixed delta time.

    Another issue I am having is random (very infrequently, but still noticeable) stuttering of the players body when moving. Correct me if I am wrong but I believe this is caused by VRIK updating in update or late update whereas my character controller and PuppetMaster are updated in Fixed Update. I think the stutter is caused when a frame is dropped and update & fixed update get out of sync. This is easily fixable by parenting the body (including VRIK and PM) onto the character controller. I assume this is a bad idea because none of your examples were setup this way. Will this setup cause incorrect physics simulation? If this is indeed bad, can I manually update VRIK and PM in fixed update? Do I need to call anything other than update on those 2 components?

    Cheers,
    Colton

    P.S Sorry for the loaded question

    EDIT: Also wondering if you offer any paid services (i.e. one on one chats etc.)?
     
    Last edited: Feb 13, 2020
  50. Redux

    Redux

    Joined:
    Nov 10, 2011
    Posts:
    146
    @Partel-Lang Does that "other method" also preserve asset/prefab linkages? One problem with how things work atm is that the setup process breaks links to original assets/prefabs on rebuild as it recreates everything. I'm not sure I follow the alternative setup either. Does this mean the animated model in the puppetmaster hierarchy after puppetmaster setup can be a different object than the rebuilt one?

    Can you do some screencaps of this in action so I can follow the steps? Thanks m8.