Search Unity

  1. All Pro and Enterprise subscribers: find helpful & inspiring creative, tech, and business know-how in the new Unity Success Hub. Sign in to stay up to date.
    Dismiss Notice
  2. Dismiss Notice

PuppetMaster - Advanced Character Physics Tool [RELEASED]

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

  1. jason416

    jason416

    Joined:
    Nov 8, 2018
    Posts:
    29
    Hey Pärtel,
    I should have included the full error. The issue also has to do with the animator not being aware of the added bones, when you call Animator.GetBoneTransform(). My animator is not aware of any added prop muscles.

    IndexOutOfRangeException: humanBoneId must be between 0 and LastBone
    UnityEngine.Animator.GetBoneTransform (UnityEngine.HumanBodyBones humanBoneId) (at /Users/builduser/buildslave/unity/build/Runtime/Animation/ScriptBindings/Animator.bindings.cs:991)
    RootMotion.Dynamics.PuppetMaster.GetHumanBodyBone (UnityEngine.Transform t, UnityEngine.HumanBodyBones[] allBones) (at Assets/Plugins/RootMotion/PuppetMaster/Scripts/PuppetMasterHumanoidConfig.cs:91)
    RootMotion.Dynamics.PuppetMaster.SaveToHumanoidConfig () (at Assets/Plugins/RootMotion/PuppetMaster/Scripts/PuppetMasterHumanoidConfig.cs:65)
     
  2. sancha-km

    sancha-km

    Joined:
    Jun 5, 2016
    Posts:
    36
    Hi,
    When script disable Animator to simulate Freeze Effect, Puppet master is activating it on the next frame. Even if it set to disabled in puppet master script settings.
    How i can avoid it?
     
    Last edited: Feb 15, 2021
  3. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,269
    Hey,
    Yes, that's the process. This is the best process for setup:

    1. Drag an instance of the character into the scene.
    2. Duplicate it
    3. Add BipedRagdollCreator to the duplicate, use it to set up the ragdoll
    4. Add PuppetMaster to the duplicate.
    5. Assign the original as "Animated Target" in PM
    6. Assign layers in PM
    7. Click on "Set Up PuppetMaster".

    Hey,

    Did you try just connecting the 2 ragdoll hands with a joint? Unpin the hanging puppet and keep the one that is not hanging pinned.
    You'll probably have to set joint.anchor and connectedAnchor to Vector3.zero if the hands are not at the same place when you add the joint.

    Hey,
    Weird I'm not getting that error when I save the config. Prop muscles have LastBone assigned for bone ID, then they're accessed by muscle index instead, so not having the prop transform part of the avatar should not be an issue.
    Can you see it with the demo Pilot in one of the demos? Or let me know how to reproduce the bug?

    Hey,
    You must be having the Animator in Animate Physics mode, which is fine, but in that mode PM is actually disabling the Animator (if it finds it enabled) and updating it in FixedUpdate every frame, then re-enabling it so you could see the live link and stuff. So you'll just need to disable it at a later time, try calling animator.enabled = false in LateUpdate.
    Also have to disable "Fix Target Transforms" in PuppetMaster or it will snap your character to default pose when you disable the Animator.

    Best,
    Pärtel
     
  4. jason416

    jason416

    Joined:
    Nov 8, 2018
    Posts:
    29
    Ok here's how to reproduce:
    If I open the PuppetExtended Demo Scene, add a prop muscle to the arm and try to save the config, it throws the error. This project is still in 2018.4.32f if that matters.
     
  5. Wonky65

    Wonky65

    Joined:
    Aug 24, 2014
    Posts:
    27
    Im very interested in the balance demo I saw in one of the videos, but I cant find it in the package? I have Final IK integration as well

    (+ How would one make character hold a box like in Final IK demos and have the weight of the box affect the character with Puppetmaster?)
     
    Last edited: Feb 20, 2021
  6. cybie

    cybie

    Joined:
    Sep 17, 2010
    Posts:
    77
    Great asset BTW!

    Question: Is there any ways you can disable a limb (say the entire left arm and hand) and just let it flop around (no animation, just unpowered joints?)

    I would like to achieve this effect but it's seems impossible. It should rather easy to do, right?
     
  7. cybie

    cybie

    Joined:
    Sep 17, 2010
    Posts:
    77
    Well just figured it out!

    The effect I want can be achieved by setting the Pin Weight and Muscle Weight to 0, while keeping there others at 1, for the entire arm/hand chain.

    Thanks!
     
  8. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,269
    Hey,
    Oh it was actually the Unity version.
    Please change line 88 in PuppetMasterHumanoidConfig.cs to this (add -1):
    Code (CSharp):
    1.  for (int i = 0; i < allBones.Length - 1; i++)
    Hey,
    It's the "Stagger (Final IK)" demo in the Final IK integration package. One of the puppets in it that only has the BehaviourBipedStagger on it, and no BehaviourPuppet, is actually an unpinned ragdoll that is self-balanced by BehaviourBipedStagger. Try pushing him with that cube in the scene. The self balancing settings are under the "Balancers" in BehaviourBipedStagger. About attaching an object, you can do so by just adding a Joint between the object and the hands, would be good to play an animation of holding that object too. But the balancers are not currently smart enough to account for that and if the object is too heavy, it will pull it off-balance. It's all highly experimental stuff though. The code is in SubBehaviourBalancer.cs if you feel like experimenting with it. Probably will just need a way to add the extra rigidbody to it's array of rigidbodies it uses to calculate center of mass.

    Hey,
    Yes, that's it. Can also do that from code, using PuppetMaster.SetMuscleWeightsRecursive().
    For example
    Code (CSharp):
    1. puppetMaster.SetMuscleWeightsRecursive(HumanBodyBones.LeftUpperArm, 0f, 0f);
    would kill the left arm.

    SetMuscleWeights.JPG

    Best,
    Pärtel
     
  9. Wonky65

    Wonky65

    Joined:
    Aug 24, 2014
    Posts:
    27
    Oh I did play around with the stagger demo, what I was looking for was just balancing the pose as best as it can, without taking steps
    ----
    and about holding/grabbing physical objects, is there easy way to grab body hitman style or hold non-kinematic rigidbody eg. a box and have it work with IK:



    In the Melee Grab & Prop Weapon demos the grabbed object seems to be kinematic (Teddy seems to not weigh at all and the low mass stick prop can easily knock people down with slight movement) ?
     
    Last edited: Feb 23, 2021
  10. cybie

    cybie

    Joined:
    Sep 17, 2010
    Posts:
    77
    I have both Final IK and Puppet Master. I try to follow the interaction system tutorial on a Puppet master ragdoll.


    However the Puppet master ragdoll only raise the hand, and the body never bend over to allow full reach. Does Puppet master work with Final IK? Did I miss something to allow the Puppet to reach to the interaction object?
     
  11. cybie

    cybie

    Joined:
    Sep 17, 2010
    Posts:
    77
    Again I think I have figure it out soon after I post. I had mess around with FBBIK's Body effector settings. And it works great! Thanks!
     
  12. cybie

    cybie

    Joined:
    Sep 17, 2010
    Posts:
    77
    What would be to best way to adjust the puppet rag doll after it's created? I have seen video which the Ragdoll editor appears when you create the rag doll, but what about if I already have a rag doll I want to adjust?
     
  13. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,269
    Hey,
    If you set "Min Angle" and "Max Angle" to 180 under the "Legs" header, it will not take any steps and just fall over when pushed off balance.

    About grabbing physical objects, there are 2 ways. One is used for stuff like weapons and that is the Prop system. Another way would be like what you see in the Melee Grab demo. The Teddy appears to have no mass just because the Pilot remains fully pinned to animation. If you added this:
    Code (CSharp):
    1. puppetMaster.SetMuscleWeightsRecursive(HumanBodyBones.Chest, 1f, 0.4f);
    as line 84 in Grab.cs to loosen the upper body a bit, you'd see more weight pulling the body.

    Hey,
    You can add the RagdollEditor component to the root of the ragdoll (PuppetMaster) at any time you like, before or after setting up PuppetMaster.

    Best,
    Pärtel
     
  14. Purpleshine84

    Purpleshine84

    Joined:
    Apr 8, 2013
    Posts:
    194
    Hello Pärtel,

    I recently bought Puppet Master but unfortunately I am not able to make it work with Adventure Creator. Invector and AC do work very well together, fortunately.

    I will describe what happens:

    Invector and AC are on the root object and Puppet Master is a child, obviously (Invector and Puppet Master work perfectly because of a plugin and a very well tutorial video on the matter).

    The thing of Puppet Master in my case is that I would like to let the character fall in a realistic way. This works, but.... after the character fell down and stands up again, it teleports ten meters away (every time I press the right or left arrow) after trying to walk again. So, something is going very wrong, and it seems that either Puppet Master or Adventure Creater messes up the gravity in the character, or it loses it's target (I'm not sure what is hapenning.. ) I hope you can help me in the right direction.
     
  15. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,269
    Hey,
    The problem must be that PuppetMaster is parented to the character controller. It must be a sibling gameobject instead. If it is parented, then it is a circular dependency issue, as PM moves the root of the character to where it should get up from, but as it is parented to it, it will also offset the ragdoll. So please try just unparenting PM from the controller. If it is a prefab and you can't parent in Editor, can unparent by script at Start.

    Best,
    Pärtel
     
    Purpleshine84 likes this.
  16. Purpleshine84

    Purpleshine84

    Joined:
    Apr 8, 2013
    Posts:
    194
    Thank you Pärtel!!
     
  17. GreenRanchGames

    GreenRanchGames

    Joined:
    Dec 18, 2020
    Posts:
    9
    Hi @Partel-Lang,

    Thanks for your previous help - my little project with floppy people is coming together nicely. I'm having another issue now - as you can see in this video clip - any significant force causes my puppet's joints to expand and the skinned mesh to stretch crazily. It's most noticeable when stepping on a land mine, which creates an explosive force, but I also noticed a similar effect in the "hanging" demo if you move the puppet around too quickly.



    I've tried fiddling with the fixed timestep, which helps a little bit, but it causes the puppets to lose some floppiness and has a hit on performance. Lowering the explosion force would also be a solution but then the puppet wouldn't go flying into the air like I want it to.

    Do you have any ideas or suggestions on how to tighten the joints of my ragdoll, specifically for cases where large amounts of force are being applied?

    Thank you!
     
  18. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,269
    Hey,
    It's just general joint instability with PhysX. If you are running Unity 2019.3 or later, set "Solver Type" to "Temporal Gauss Seidel" in Physics Settings. That is a new much more stable joint solver.
    If you can't update to that, try increasing rigidbody.solverVelocityIterations for all the ragdoll rigidbodies.

    Best,
    Pärtel
     
  19. GreenRanchGames

    GreenRanchGames

    Joined:
    Dec 18, 2020
    Posts:
    9

    The Temporal Gauss Seidel option helped a lot. I didn't even know about this setting until now. Thanks a bunch!
     
  20. cybie

    cybie

    Joined:
    Sep 17, 2010
    Posts:
    77
    Hi Partel, Is there a to trigger the Stagger Behaviour by calling a function (rather than physically making the ragdoll loose balance) ?

    Thanks.
     
  21. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,269
    Hey,
    If you're using BehaviourPuppet, just call behaviourPuppet.SetState(BehaviourPuppet.State.Unpinned) and it will switch over to the stagger behaviour, provided you have "Switch To Behaviour" set in BehaviourPuppet's "On Lose Balance" event.

    Best,
    Pärtel
     
    cybie likes this.
  22. Futwerk

    Futwerk

    Joined:
    Jun 21, 2020
    Posts:
    6
    Hi Pärtel,

    Each time my character falls, after getting back up it floats above the ground and does the rest of its animations floating above the ground. If it loses balance again, it falls to the actual ground, but when it gets back up it floats again. The character does not have foot colliders, if that makes a difference.
    I tried:
    • Using custom animations and the ones that come with Puppetmaster
    • Adjusting the colliders on the character's shins so that they are close to the ground (ie. they go down to where the feet are)
    • Enabling and disabling footIK in the Mechanim settings.
    The issue still persists. Any help would be appreciated.

    Thank you
     
  23. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,269
    Hey,
    Do you have some kind of a character controller on it, like Unity's CharacterController or a rigidbody with a capsule collider? A character controller with gravity should keep it grounded.

    Best,
    Pärtel
     
  24. joshuaharristx

    joshuaharristx

    Joined:
    Apr 1, 2019
    Posts:
    30
    Hello Partel,

    I am wanting to set my PuppetMaster rig to Kinematic during its getup or have the same effect at least. My models legs seems to get a little spazzy if it is in active mode during the animation. The issue is the behaviour puppet script forces it back to active. I have tried setting it to kinematic each frame during the getup but that seems a inefficient. I have also notice some odd behavior with props not having their position updated while a rig is in kinematic mode. I cannot find this issue anywhere else though, have you come across it before?
     
  25. Futwerk

    Futwerk

    Joined:
    Jun 21, 2020
    Posts:
    6
    My apologies I just realized what the issue is: I had accidentally changed the layer my ground area was set to. I changed it back to "Water" and now it works fine.
     
  26. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,269
    Hey,
    Can't be kinematic while in getting up mode because PM is blending from ragdoll to animation at that time.
    Have you tried instead of changing PuppetMaster mode, to set BehaviourPuppet's "Normal Mode" to Kinematic or Unmapped? That handles it already. Decreasing "Min Get Up Duration" in BP might help too.
    I haven't noticed props not updating their position, can you tell me how to reproduce that?

    Best,
    Pärtel
     
  27. pan-master

    pan-master

    Joined:
    Nov 11, 2013
    Posts:
    126
    Character is not Fallowing, Ragdall(ragdall moves according to puppetmaster settings) however main character mesh fallows Animator animation, and not RAGDoLL
     
  28. Dynablaster

    Dynablaster

    Joined:
    Feb 28, 2014
    Posts:
    7
    Hi there Partel. I got both Final IK and PuppetMaster. First of all I love both of them and their potential but I am at loss at how to get PuppetMaster working with the character controller I am using(its called Character Controller PRO). I got really comfortable with this controller and I dont want to switch to another one just because I cant get these two to cooperate. The problem might be simple or impossible to solve I have no idea so I need your help.

    The difference from your controllers in your examples to this one I am using is in the hierarchy. My one has Player root(on which the character controller script is attached, collider and rigidbody) but the animator is not on it. There is child of the root called Graphics and in that there is finally a child with the animator and in it is the armature and skinned renderer. So its like this:
    Player root(collider, rigidbody, controller script)
    Graphics
    Character(with animator)
    Hips(armature)
    Is it possible to get this to work with a PuppetMaster?

    EDIT: As always, whenever you give up and go ask somebody you figure some stuff out... What happened before when I went to create the ragdoll I duplicated the the object with the animator and armature and made ragdoll of it then attached the puppetmaster script and what that did is I had two objects in the scene with armature and animator. I could point to the the right animator root object in my Player hierarchy but I didnt realize that didnt change the targets in the puppetmaster so I went and changed them manually and deleted that second animator object. Not most elegant way but it works now so I am happy :D

    So my next issue is I have aim IK and look IK on my upper body so that has issues too because I dug into this thread and from what I understand I need update IK on delegate event. is that correct? But I can live even without getting IK and puppet working smoothly I dont mid having the character in kinematic mode then firing the ragdoll on death. I mean I wouldnt mind having some of the benefits of procedural animation but right now even when I turn off IK the puppet is jittery. Any idea why it is acting that way in simple walk and run animation?
     
    Last edited: Mar 29, 2021
  29. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,269
    Hey,
    Do you have "Normal Mode" set to "Unmapped" or "Kinematic" in BehaviourPuppet. If so, then it will not follow the ragdoll until there is a collision with something that is on the "Collision Layers". Then it will blend mapping in until the collision is resolved and blend out again. It's used for maintaining max animation accuracy while you don't need PM.

    Hey,
    If the motion is jittery, that's usually the camera's motion not being in sync with the character. Make sure you have all the ragdoll rigidbodies and the character controller rigidbody interpolating, make sure your camera controller script updates in LateUpdate and it has been set to a higher value in the Script Execution Order than PuppetMaster.cs has.

    You should be also able to use AimIK and LookAtIK on the character. Only need to use delegates if you need to change the order in which they are updated.

    Best,
    Pärtel
     
  30. billnguyenme

    billnguyenme

    Joined:
    Dec 5, 2020
    Posts:
    89
    I'm very interested in this asset for my project. I was wondering if it will clash with character controllers which that move without rag dolls. I'm currently using KinematicCharacterController for my player controller at the moment.

    What I'm looking to do:

    Character trips over colliders on their ragdoll limbs which is on a different layer than the CharacterController capsule, once they get up to their idle/run position it will then revert to using character controller for movement.

    Characters arms collide with colliders whilst all other limbs are unaffected. Think of an FPS where the characters arm is out.
     
  31. Purpleshine84

    Purpleshine84

    Joined:
    Apr 8, 2013
    Posts:
    194
    Hello Pärtel,

    I have a problem: I have a scene for testing purposes where my character with PuppetMaster is absolutely fine (see the second image), but when I place this same character with PuppetMaster in one of my other scenes I have a lot of stretching, see the first image. The neck and arms are too long - it looks almost like PuppetMaster changes the whole Avatar from the character into some stretching weird character. I already read all the posts here about stretching, and try to solve the iterations in the Physics settings tab and to put the iterations on PuppetMaster (or any other button) in the PuppetMaster tab, but absolutely no succes, everything stays the same. I even deleted all objects from the scenes where I have this strange stretch and it still stretches(!) So I'm totally lost here. What could be the cause and what could I do about it? I am using Unity 2018.4 btw. I hope you can help.



    Twinsen_Stretch.PNG Twinsen_nostretch.PNG
     
  32. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,269
    Hey,
    Yes you can do that. I also have an example/integration package for KinematicCharacterController, can import it from Plugins/RootMotion/PuppetMaster/_Integration folder.

    Hey,
    I have not seen a stretching issue like that before. Does it happen when you make a new empty scene with just a ground collider and the puppet? Are there any warnings or errors coming from PM in the Console?

    Best,
    Pärtel
     
    billnguyenme likes this.
  33. Purpleshine84

    Purpleshine84

    Joined:
    Apr 8, 2013
    Posts:
    194
    Thank you for answering. In an empty scene the puppet is just fine. It is in both other gameplay-scenes that the puppet is stretching, and there are no warnings or whatsoever. And even when I delete everything from this scenes the problem stays. I don't get that. How can a problem stay if there is nothing in the scene?

    To be more clear: The player in the empty scene (With adventure creator/Invector etc) is just the same as the one in the gameplay scenes. Apart of Bakery and Enviro skies nothing strange in that scene (I should think?). But even after I deleted everything the ragdoll stretches like an alien. Physics layers are also fine, I looked days to that, and they don't seem to change outside the scene. Surely there must be something I am missing, but I don't know what to check anymore since nothing seems to be left to check.

    EDIT: Just made an empty character in the gameplay scene, and appears to be something on the character! I will write here again if I found the problem.
    EDIT 2: Found it! It was very silly: apparently there was a script on my character that modified the local scale of the character for certain scenes, that also explained why it did work in the scene that wasn't added to the build settings. This was even a custom script I wrote myself, so it was a really dumb mistake. Sorry to bother!
     
    Last edited: Apr 2, 2021
    Partel-Lang likes this.
  34. Purpleshine84

    Purpleshine84

    Joined:
    Apr 8, 2013
    Posts:
    194
    Hi @Partel-Lang, the integration with Adventure Creator is almost finished, just one thing: I have problems with scene switching and spawning: The character's PuppetMaster falls on the ground and I get the following error:


    NullReferenceException: Object reference not set to an instance of an object
    RootMotion.Dynamics.PuppetMaster.Update () (at Assets/Plugins/RootMotion/PuppetMaster/Scripts/PuppetMaster.cs:1056)

    And here the line in the script:

    foreach (BehaviourBase b in behaviours) b.UpdateB(Time.deltaTime);
    NullReferenceException: Object reference not set to an instance of an object
    RootMotion.Dynamics.PuppetMaster.LateUpdate () (at Assets/Plugins/RootMotion/PuppetMaster/Scripts/PuppetMaster.cs:1076)

    And here the line in the script:
    foreach (BehaviourBase b in behaviours) b.LateUpdateB(Time.deltaTime);

    I have had a very long confersation with Chris Icebox, the maker from Adventure Creator to point out the problem and find the solution, and then he pointed back to you about this error message, about the meaning behind it.

    Here is the Thread: https://adventurecreator.org/forum/discussion/11185/adventure-creator-and-puppet-master/p1
    It is two pages, but I also made a video which makes the problem even more clear I think (see the last two minutes, because seven minutes might be a bit long - sorry for that in advance):
    From 4.51 -


    I hope very much you can point us in the right direction :)
     
    Last edited: Apr 9, 2021
  35. Purpleshine84

    Purpleshine84

    Joined:
    Apr 8, 2013
    Posts:
    194
    Ok, finally - my brother and me worked on it, since he does the programming, we founded the solution. It is fantastic since you can still use prefabs and don't change anything in AC. Basically the following script which was for 50 procent written by Chris IceBox from Adventure Creator (the teleporting of PM) and 50 procent by my other brother (also named Chris haha), that unparent and reparents PuppetMaster and solves the scene switching problems. Put this on your Player and you are good to go.

    Code (CSharp):
    1. using AC;
    2. using RootMotion.Dynamics;
    3. using System.Collections;
    4. using System.Collections.Generic;
    5. using UnityEngine;
    6.  
    7. public class PlayerPMActivator : MonoBehaviour
    8. {
    9. /*
    10. * AdventureCreator PupperMaster Player Activator
    11. *
    12. * Problem: PuppetMaster player container not compatible with AdventureCreator Player prefabs.
    13. *
    14. * Resolution/to use: First use PuppetMaster as instucted. Then put PuppetMaster under the Player and
    15. * make sure it is deactivated by default. Make the player into a prefab and assign in AC.
    16. * Add this script to the Player.
    17. *
    18. * Also:
    19. * - Make sure this gets executed before other scripts that mess with the Player/NPC.
    20. *
    21. */
    22.  
    23. private Char character;
    24. private PuppetMaster puppetMaster;
    25.  
    26. void Awake()
    27. {
    28.  
    29.    GameObject target = null;
    30.    foreach (Transform go in GetComponentsInChildren<Transform>(true))
    31.    {
    32.        if (go.gameObject.name == "PuppetMaster")
    33.        {
    34.            target = go.gameObject;
    35.            break;
    36.        }
    37.    }
    38.  
    39.    puppetMaster = target.GetComponent<PuppetMaster>();
    40.  
    41.    // Uncomment to put Player itself inside parent GameObject
    42.  
    43.    //GameObject gn = new GameObject("Player_Container");
    44.    //gn.layer = LayerMask.NameToLayer("Player");
    45.    //gn.tag = "Player";
    46.    //this.transform.SetParent(gn.transform);
    47.  
    48.    target.transform.SetParent(null);
    49.    DontDestroyOnLoad(target);
    50.    target.SetActive(true);
    51.  
    52. }
    53.  
    54. private void OnTeleport()
    55. {
    56.    if (character == null) character = GetComponent<Char>();
    57.    puppetMaster.Teleport(character.Transform.position, character.Transform.rotation, true);
    58.    Debug.Log("Teleported PuppetMaster to " + character.Transform.position);
    59.    character.Transform.localPosition = Vector3.zero;
    60. }
    61. }
     
  36. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,269
    Hey,
    That line can produce a nullreferenceexception only if BehaviourPuppet or BehaviourFall has been added, but later destroyed for some reason.

    Best,
    Pärtel
     
  37. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    442
    Today I mentioned puppet master doesn't work anymore when I use floating origin script! That's weird because as I remember it wasn't a problem before I think this happened after update!?! Can you please compatible puppet master with floating origin script? My project is at risk now :(
     
  38. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,269
    Hey,
    What exactly is not working, are you seeing jitter or something else?
    I can send you the previous version, but would rather try and figure out what is going on first.

    Best,
    Pärtel
     
  39. Nightkin99

    Nightkin99

    Joined:
    May 11, 2018
    Posts:
    5
    Hi Pärtel,

    I am trying to do something rather weird with Puppet Master and I'm not sure how to proceed. Without using Puppet Master, working only with the traditional bones of the character it goes like this : I have written what I call a "PostureCorrecter" script that allows the user to set some bones to some pre-defined angles, either relative to their current rotation or absolute, and either with explicit numbers or with angles taken from other limbs, that takes place after animating the character. For example, this allows me to simulate high heels by artificially adding, say, 40° on X to each foot and substracting 40° on X to the toes (that's just an example, and offseting the height of the character to account for this late rotation is handled by another script). That script also allows me to make one limb imitate the other, with or without offset, a bit like setting hard constraints. Although it works well for an animated character, it fails miserably with the Puppet Master bones since they are physical. It makes the limbs jitter at best, and the simulation explode completely at worst, sending the puppet fly all over the place. I need to precise that I deactivate the internal collisions for testing purposes but it still jitters or explodes.

    I would like to reuse my "PostureCorrecter" script to do the same thing whether it is set to manipulate the traditional bones or the PM bones, as a sort of post-processing thing. In other words, after PM is done solving, I'd like to be able to move some of its bones the way I want without influencing the simulation in the next cycle. Since I move the PM bones in OnWrite, I have to move them back in OnRead to avoid accumulating the offsets in the angles but this is not enough, I guess PM (or PhysX ?) detects that the bones have been moved violently and deduces the velocity and tries to compensate, which would explain the jitter. I have a hunch that instead of moving the bones I should command the muscles to do it for me but I have no idea how nor if it would be as precise as I want it to be. Basically what I want is to be able to tell PM "the X angle of the left thigh must be exactly 10° higher than the X angle of the right thigh, at any time and without any jitter". I have FinalIK too but this would help only with the hands and feet, not the other bones I want to offset.

    I'd be grateful for any pointers. Thanks !
     
  40. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,269
    Hey,
    Did you use OnRead or LateUpdate to run the pusture correction? If you used LateUpdate and happen to have the Animator at Animate Physics mode, then you'll get jitter as animation is only applied in FixedUpdate, but the offsetting every frame. You'd have to use OnRead (which already handles that) or LateUpdate only if a FixedUpdate has been called earlier that frame.

    Also make sure you are not rotating any bones under PuppetMaster hierarchy. Do the posture correction on the animated hierarchy, then PuppetMaster will follow as it was just normal animation.

    Code (CSharp):
    1. public Animator animator;
    2. public Vector3 leftFootRotOffset;
    3.  
    4. private Transform leftFoot;
    5.  
    6. void Start() {
    7. puppetMaster.OnRead += OnPuppetMasterRead();
    8. leftFoot = animator.GetBoneTransform(HumanBodyBones.LeftFoot);
    9. }
    10.  
    11. private void OnPuppetMasterRead() {
    12. leftFoot.localRotation *= Quaternion.Euler(leftFootRotOffset);
    13. }
    If you use OnWrite, then that will be applied on top of everything, the physics will not respond to that anymore. That method is used for making minor cosmetic corrections. But again, rotate the animated bones, not PM ones.
     
  41. Nightkin99

    Nightkin99

    Joined:
    May 11, 2018
    Posts:
    5
    Thank you for your quick answer.

    Yyyyeah, that's the thing, I do need to rotate the PM bones, not the animated ones. I actually don't want to have anything to do with traditional animations (except for minor movements like the eyes, the head to make the character look around, some breathing and such, but nothing that actually moves the bones that I want PM to animate for me), I need the character to be entirely physical. But with the additional constraint that some limbs must sometimes be rotated according to other limbs. After PM has done its solving in the cycle, and without making my character fly all over the place doing so.

    To answer your questions, I use both OnRead and OnWrite. To give a simple example, if I want the right thigh to be offset by 10° forward after the puppet solver has been executed, then I need to offset it 10° backward first (in the delegate assigned to OnRead) in order to avoid accumulating this additional angle every frame and pulling the leg forward all the time.
     
  42. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,269
    You can't just rotate rigidbody transforms without messing up the physics.

    Here, please import this package, made a quick example for you. Used HumanPoseHandler to create procedural "animation", but you might as well just set bone rotations from OnRead, doesn't matter for PuppetMaster.

    Best,
    Pärtel
     
  43. Nightkin99

    Nightkin99

    Joined:
    May 11, 2018
    Posts:
    5
    Thank you for the example package, and for making it clear that posing the PM bones directly is not the solution. I indeed initially used poses in the animator too, like you did, to force the puppet to assume pretty much the same pose (or a part of it) but that's not always possible for what I need the puppet to do because in some cases I need precision to the degree while still making the limb physical. So sometimes I do need to make some puppet bones imitate some other puppet bones (with or without offset, mirrored, etc). Ideally without making the puppet blow up in my face or go to orbit.

    One solution I can think of is this. When I need bone A to imitate another bone B, both in the PM hierarchy, I would first deactivate bone A (mapping, pin and muscle weights to 0 for that specific muscle). Then my PostureCorrecter would modify the rotations of the animated counterpart of bone A according to the PM bone B without caring about the PM bone A at all. That way, all I need to care about is the joints limits, making sure they are permissive enough for the limb I'm trying to control to mirror another limb. The result would be both limbs would appear to be physical while only one of them is controlled by PM, the other would only mirror it. The downside of this solution is that PM bone A would have to be weightless and float around freely, maybe colliding into stuff and pushing the puppet when it does, while visually nothing touches the body since the visual aspect of this limb would be elsewhere. It's just an idea, I have yet to implement it.
     
  44. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    442
    When floating origin script shift the world it separates puppet master from character! It falls down from map. If I disable and active the mode inside puppet master script it will come back to character and everything looks correct again but if I use this method for all my characters that can hit performance
     
    Last edited: Apr 16, 2021
  45. Nightkin99

    Nightkin99

    Joined:
    May 11, 2018
    Posts:
    5
    So I implemented the idea I had earlier and it did the trick. One bone of the animated hierarchy copies the rotation of the symmetric bone of the PM hierarchy, while the PM counterpart of the former is left weightless, floating without hindering the movement of the puppet (no internal collisions, mapping weight 0, muscle damper 0). It's not perfect but it good enough for my needs. Thanks a lot for your help !

    PS : It would be great if we could deactivate some PM bones selectively, like a whole arm or a whole leg.
     
  46. insane245

    insane245

    Joined:
    Jun 28, 2016
    Posts:
    10
    Hi Partel, hope you're doing well! I've been posting Devlogs on my YouTube and a viewer wanted to know how the camera following works: "Hey man, how did you make your third person camera system. Mine seems a bit jittery and its hard to aim at a specific point?" I used your camera following code from the sample scenes. Basically, how much can I share with others who don't own your asset? I want to help but I don't want to give away your code. I would probably just show him some code snippets and mention PuppetMaster. Maybe even make a tutorial video if later on it's cool with you.

    Thank you,
    James
     
  47. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,269
    I guys, sorry for the delay, was on vacation last week.

    Hey,
    That's not possible, I'm afraid, but you can disable mapping for each individual muscle - muscle.props.mappingWeight to 0, so the animated body part would not be mapped to the ragdoll.

    Yes, sharing tutorals, snippets, tips and tricks is perfectly fine by my and makes my support job easier, thank you!

    Cheers,
    Pärtel
     
    Crossway likes this.
  48. giraffe1

    giraffe1

    Joined:
    Nov 1, 2014
    Posts:
    215
    Would it be possible to make a simpler example demo for Getting up from back/stomach? Something similar to the 'death procedure' demo.

    I am trying to study the 'puppet extended' demo to figure it out but there is a lot of other stuff going on in that demo so it is a bit harder to follow the code.

    Thanks
     
  49. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,269
    Hey,
    You mean you are making your own version of BehaviourPuppet basically?
    The code that handles getting up is in BehaviourPuppetStateSwitching.cs starting with line 133. Basically what you need to do first is check whether the ragdoll is prone or supine. Can do that by checking if the forward axis of the pelvis rigidbody is pointing down or up (line 171), play the getting up animation based on that. Then move the target root horizontally to the pelvis rigidbody, vertically on the ground. After that, just blend in pin weights.

    Best,
    Pärtel
     
  50. kollege14a5

    kollege14a5

    Joined:
    Jul 23, 2019
    Posts:
    2
    Hi Guys,

    I recently started working with puppet master and I encountered the problem that if I manually unpin the puppet via BehaviourPuppet.SetState(BehaviourPuppet.State.Unpinned) while I am jumping or falling down the puppet loses its momentum. It seems that the puppet slightly teleports while the animated character keeps going normally and then teleports into the position of the Puppet.

    If I unpin the character while having 0 velocity in y direction everything works fine. What am I doing wrong? Can someone help me out?

    Thanks
     
    Last edited: May 2, 2021
unityunity