Search Unity

PuppetMaster - Advanced Character Physics Tool [RELEASED]

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

  1. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,968
    Hey,
    Yes, if you have bones, it is possible ("Partial Pinning" demo in the package).

    Hey,
    Please add this segment to the top of PuppetMasterModes.cs:
    Code (CSharp):
    1. /// <summary>
    2.         /// Switches this PuppetMaster to PuppetMaster.Mode.Active.
    3.         /// </summary>
    4.         public void SwitchToActiveMode()
    5.         {
    6.             mode = Mode.Active;
    7.         }
    8.  
    9.         /// <summary>
    10.         /// Switches this PuppetMaster to PuppetMaster.Mode.Kinematic.
    11.         /// </summary>
    12.         public void SwitchToKinematicMode()
    13.         {
    14.             mode = Mode.Kinematic;
    15.         }
    16.  
    17.         /// <summary>
    18.         /// Switches this PuppetMaster to PuppetMaster.Mode.Disabled.
    19.         /// </summary>
    20.         public void SwitchToDisabledMode()
    21.         {
    22.             mode = Mode.Disabled;
    23.         }
    I will add this change into the next version too.

    Hey,
    The manual. If you have any specific suggestions to improve it, I'd be happy to hear them. Also, there is quite a lot of information in the tooltips of PuppetMaster and BehaviourPuppet components and some tutorials here.

    Best,
    Pärtel
     
    ksam2 likes this.
  2. flow-

    flow-

    Joined:
    Apr 19, 2015
    Posts:
    143
    Hey, i got some problems with a very unusual situation.
    I want that the player is able to Climb up this Mammoth.
    2mammoth.png

    I use Puppet Master now like a half year and i wonder if i can do this with Props.
    I already have created anchor Points and Instantiated Props on this anchor points, it works somehow when i add a FixedJoint between this but the problem is that the prop totally freaks out, i think it's because the Fixed Joint is to static and interference with the Configurable Joint.

    Any Suggestions how i can just connect the ragdoll on this anchor points?

    EDIT:
    I realized it's a problem on the PhysX Joints, they just become unpredictable and getting unstable when i try to connect a ragdoll on it...
    I try now to create a pivot point on the character Hips while he is in the air so i can work locally with the extremities joints to not have the full weight on the extremities.
     
    Last edited: May 22, 2019
  3. docseuss

    docseuss

    Joined:
    Apr 5, 2016
    Posts:
    41
    Pärtel,
    Just want to say that I have been really enjoying PuppetMaster and FinalIK. However I was trying to attach PuppetMaster and FinalIK to UMA 2.8 and the examples you provide are a bit outdated as with 2.8 they changed the UMA stuff quite a bit. Anyhow I have updated and changed your scripts to work with UMA 2.8 and thought I would post them here for others to use.

    To use these scripts just add AttachPuppetMaster and AttachFinalIK to your UMA Avatar and then in the UMA Created Events just reference them (See screenshot).

    AttachPuppetMaster
    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using RootMotion.Dynamics;
    4. using UMA.CharacterSystem;
    5. using RootMotion;
    6. using GambitMonkey.Utils;
    7.  
    8. namespace GambitMonkey.UMA {
    9.  
    10.     public class AttachPuppetMaster : MonoBehaviour {
    11.  
    12.         [Header("Assign Avatar To Build")]
    13.         public DynamicCharacterAvatar avatar;
    14.  
    15.         [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.")]
    16.         [LayerAttribute]
    17.         public int characterControllerLayer;
    18.  
    19.         [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.")]
    20.         [LayerAttribute]
    21.         public int ragdollLayer;
    22.  
    23.         [Header("PuppetMaster Config")]
    24.         public PuppetMasterHumanoidConfig humanoidConfig;
    25.  
    26.         [Tooltip("Ragdoll Collider customizations")]
    27.         [Header("Ragdoll Colliders")]
    28.         public float footCorrectionAngle = 30f;
    29.         public Vector3 headColliderCenter = new Vector3(-0.03f, 0f, .04f);
    30.         public float headColliderRadius = 0.1f;
    31.         public float headColliderHeight = 0.3f;
    32.                
    33.         [Header("Behaviours")]
    34.         public BehaviourBase[] behaviourPrefabs;
    35.  
    36.         public void AddPuppetMaster()
    37.         {
    38.             if (avatar != null)
    39.             {
    40.                 // Auto-generate a ragdoll and set up PuppetMaster to an UMADynamicAvatar
    41.                PuppetMaster pm = PuppetMasterUMATools.SetUp(avatar, characterControllerLayer, ragdollLayer, OnEditOptions, OnEditRagdoll);
    42.  
    43.                 // Add the behaviours
    44.                 Transform behaviourRoot = avatar.transform.parent.Find("Behaviours");              
    45.  
    46.                 foreach (BehaviourBase prefab in behaviourPrefabs)
    47.                 {
    48.                     BehaviourBase behaviour = (BehaviourBase)GameObject.Instantiate(prefab, avatar.transform.position, avatar.transform.rotation);
    49.                     behaviour.transform.parent = behaviourRoot;
    50.  
    51.                     if (behaviour is BehaviourPuppet)
    52.                     {
    53.                         // Ignore collisions with BehaviourPuppet collision layers and the character controller layer
    54.                         int[] indexes = LayerMaskExtensions.MaskToNumbers((behaviour as BehaviourPuppet).collisionLayers);
    55.  
    56.                         foreach (int index in indexes)
    57.                         {
    58.                             Physics.IgnoreLayerCollision(avatar.gameObject.layer, index);
    59.                         }
    60.                     }
    61.                 }
    62.  
    63.                 /*
    64.                 if (behaviourPuppetPrefab != null && behaviourFallPrefab != null) {
    65.                     Transform behaviours = avatar.transform.parent.FindChild("Behaviours");
    66.  
    67.                     GameObject puppet = (GameObject)GameObject.Instantiate(behaviourPuppetPrefab, avatar.transform.position, avatar.transform.rotation);
    68.                     puppet.transform.parent = behaviours;
    69.  
    70.                     GameObject fall = (GameObject)GameObject.Instantiate(behaviourFallPrefab, avatar.transform.position, avatar.transform.rotation);
    71.                     fall.transform.parent = behaviours;
    72.  
    73.                     // Ignore collisions with BehaviourPuppet collision layers and the character controller layer
    74.                     int[] indexes = LayerMaskExtensions.MaskToNumbers(puppet.GetComponent<BehaviourPuppet>().collisionLayers);
    75.                     foreach (int index in indexes) {
    76.                         Physics.IgnoreLayerCollision(avatar.gameObject.layer, index);
    77.                     }
    78.                 }
    79.                 */
    80.  
    81.                 //Sets the values of the UMA PuppetMaster from a humanoid config
    82.                 if (pm != null && humanoidConfig != null)
    83.                 {
    84.                     pm.humanoidConfig = humanoidConfig;
    85.                 }
    86.  
    87.                 Debug.Log("PuppetMaster successfully set up with " + avatar.name);
    88.                 avatar = null; // Do not set up to the same avatar again (we're in Update)
    89.             }
    90.         }
    91.  
    92.         void OnEditOptions(ref BipedRagdollCreator.Options options) {
    93.             /* // Params of BipedRagdollCreator.Options that you can specify here, just for reference
    94.             options.weight *= 2f; // Double the mass of the character
    95.             options.spine = false; // No spine collider
    96.             options.chest = false; // No chest collider
    97.             options.hands = false; // No hand colliders
    98.             options.feet = false; // No foot collider
    99.  
    100.             options.jointRange = 2f; // Make the joint limits double as wide
    101.  
    102.             options.colliderLengthOverlap = 0.1f; // Make the colliders overlap each other a bit more
    103.             options.torsoColliders = RagdollCreator.ColliderType.Capsule; // Use CapsuleColliders for the torso
    104.             options.headCollider = RagdollCreator.ColliderType.Box; // Use BoxCollider for the head
    105.             options.armColliders = RagdollCreator.ColliderType.Box; // Use BoxColliderss for the arms
    106.             options.handColliders = RagdollCreator.ColliderType.Box; // Use BoxColliders for the hands
    107.             options.legColliders = RagdollCreator.ColliderType.Box; // Use BoxColliders for the legs
    108.             options.footColliders = RagdollCreator.ColliderType.Capsule; // Use CapsuleColliders for the feet
    109.             */                      
    110.         }
    111.  
    112.         // Called by PuppetMasterUMATools when the ragdoll has been created, but before setting it up with PM
    113.         void OnEditRagdoll(BipedRagdollReferences references) {
    114.             // Make programmatic adjustmets to the auto-generated ragdoll if necessary
    115.            
    116.             // We can rotate the feet of the ragdoll to account for the foot bone orientatios not being aligned with the ground
    117.             Quaternion footCorrection = Quaternion.Euler(0f, footCorrectionAngle, 0f);
    118.             references.leftFoot.localRotation = footCorrection * references.leftFoot.localRotation;
    119.             references.rightFoot.localRotation = footCorrection * references.rightFoot.localRotation;
    120.  
    121.             // If using CapsuleCollider for the head
    122.             var headCapsule = references.head.GetComponent<CapsuleCollider>();
    123.             if (headCapsule != null)
    124.             {
    125.                 headCapsule.center += headColliderCenter;
    126.                 headCapsule.radius = headColliderRadius;
    127.                 headCapsule.height = headColliderHeight;
    128.             }
    129.  
    130.             // If using BoxCollider for the head
    131.             //var headBox = references.head.GetComponent<BoxCollider>();
    132.             //if (headBox != null)
    133.             //{
    134.             //    headBox.center += headColliderCenter;
    135.             //    headBox.size *= 0.1f;
    136.             //}
    137.         }
    138.     }
    139. }
    140.  
    PuppetMasterUMATools
    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using UMA.CharacterSystem;
    4. using RootMotion.Dynamics;
    5.  
    6. namespace GambitMonkey.UMA {
    7.  
    8.     public class PuppetMasterUMATools : MonoBehaviour {
    9.  
    10.         public delegate void EditOptions(ref BipedRagdollCreator.Options options);
    11.         public delegate void EditRagdoll(BipedRagdollReferences references);
    12.  
    13.         public static PuppetMaster SetUp(DynamicCharacterAvatar avatar, LayerMask characterControllerLayer, LayerMask ragdollLayer, EditOptions OnEditOptions = null, EditRagdoll OnEditRagdoll = null)
    14.         {
    15.             if (avatar == null) {
    16.                 Debug.Log("UMADynamicAvatar is null, can not set up PuppetMaster");
    17.                 return null;
    18.             }
    19.  
    20.             Animator animator = avatar.GetComponent<Animator>();
    21.  
    22.             if (animator == null) {
    23.                 Debug.Log("UMADyncamiAvatar has no Animator component, can not set up PuppetMaster");
    24.                 return null;
    25.             }
    26.  
    27.             GameObject ragdoll = GameObject.Instantiate(animator.gameObject, animator.transform.position, animator.transform.rotation);
    28.             Animator ragdollAnimator = ragdoll.GetComponent<Animator>();
    29.  
    30.             Transform newRagdollRoot = new GameObject("Ragdoll Root").transform;
    31.             newRagdollRoot.position = animator.transform.position;
    32.             newRagdollRoot.rotation = animator.transform.rotation;
    33.             newRagdollRoot.parent = animator.transform.parent;
    34.             ragdoll.transform.GetChild(0).parent = newRagdollRoot;
    35.  
    36.             // Find bones (UMA)
    37.             BipedRagdollReferences r = BipedRagdollReferences.FromAvatar(ragdollAnimator);
    38.            
    39.             r.root = newRagdollRoot;
    40.             BipedRagdollCreator.Options options = BipedRagdollCreator.AutodetectOptions(r);
    41.            
    42.             // Edit options here if you need to
    43.             if (OnEditOptions != null) OnEditOptions(ref options);
    44.  
    45.             BipedRagdollCreator.Create(r, options);
    46.  
    47.            if (OnEditRagdoll != null) OnEditRagdoll(r);
    48.            
    49.             PuppetMaster pm = PuppetMaster.SetUp(animator.transform, newRagdollRoot, characterControllerLayer, ragdollLayer);          
    50.  
    51.             DestroyImmediate(ragdollAnimator);
    52.             DestroyImmediate(ragdoll);
    53.            
    54.             animator = null;
    55.             return pm;
    56.         }
    57.     }
    58. }
    59.  
    AttachFinalIK
    Code (CSharp):
    1.  
    2. using RootMotion;
    3. using RootMotion.FinalIK;
    4. using UnityEngine;
    5. using static RootMotion.FinalIK.GrounderFBBIK;
    6.  
    7. namespace GambitMonkey.UMA
    8. {
    9.     public class AttachFinalIK : MonoBehaviour
    10.     {
    11.         FullBodyBipedIK ik;
    12.         GrounderFBBIK gk;
    13.      
    14.         public LayerMask groundLayer;
    15.         public SpineEffector[] spine;
    16.      
    17.         public void AddFBBIK()
    18.         {
    19.             BipedReferences references = null;
    20.             GameObject go = this.gameObject;
    21.  
    22.             if (references == null)
    23.             { // Auto-detect the biped definition if we don't have it yet
    24.                 BipedReferences.AutoDetectReferences(ref references, go.transform, BipedReferences.AutoDetectParams.Default);
    25.             }
    26.             ik = go.AddComponent<FullBodyBipedIK>(); // Adding the component          
    27.             ik.SetReferences(references, null);
    28.             ik.solver.SetLimbOrientations(BipedLimbOrientations.UMA); // The limb orientations definition for UMA skeletons
    29.             Debug.Log("Successfully Added FBBIK");
    30.         }
    31.  
    32.         public void AddGrounderFBBIK()
    33.         {
    34.             GameObject go = this.gameObject;
    35.  
    36.             //Add GrounderIK for feet orientation
    37.             gk = go.AddComponent<GrounderFBBIK>();
    38.             if (ik != null)
    39.             {
    40.                 gk.ik = ik;
    41.                 gk.solver.layers.value = groundLayer.value;
    42.                 gk.spine = spine;
    43.                 Debug.Log("Successfully Added GrounderFBBIK");
    44.             }
    45.         }
    46.     }
    47. }
    48.  
    LayerMaskSingleEditor
    Code (CSharp):
    1.  
    2. using GambitMonkey.Utils;
    3. using UnityEditor;
    4. using UnityEngine;
    5.  
    6. namespace GambitMonkey.Editors
    7. {
    8.     [CustomPropertyDrawer(typeof(LayerAttribute))]
    9.     public class LayerMaskSingleEditor : PropertyDrawer
    10.     {
    11.         public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    12.         {
    13.             EditorGUI.BeginProperty(position, label, property);
    14.             int index = property.intValue;
    15.             if (index > 31)
    16.             {
    17.                 Debug.Log("CustomPropertyDrawer, layer index is to high '" + index + "', is set to 31.");
    18.                 index = 31;
    19.             }
    20.             else if (index < 0)
    21.             {
    22.                 Debug.Log("CustomPropertyDrawer, layer index is to low '" + index + "', is set to 0");
    23.                 index = 0;
    24.             }
    25.             property.intValue = EditorGUI.LayerField(position, label, index);
    26.             EditorGUI.EndProperty();
    27.         }
    28.     }
    29. }
    30.  
    31.  
    LayerAttribute
    Code (CSharp):
    1.  
    2. using UnityEngine;
    3.  
    4. namespace GambitMonkey.Utils
    5. {
    6.     /// <summary>
    7.     /// Attribute to select a single layer.
    8.     /// </summary>
    9.     public class LayerAttribute : PropertyAttribute
    10.     {
    11.     }
    12. }
    13.  
     

    Attached Files:

    Last edited: May 25, 2019
  4. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,968
    Hey,
    Would also like to point out that if you add joints that connect the PuppetMaster ragdoll to anything else, you'll have to set pin weight to 0 for the puppet or at least the body part that was connected, because the pinning forces would try to keep the ragdoll pinned to the animation and the added joint would conflict with that and they would end up pulling the ragdoll to pieces when the forces get big enough.

    Hey, thank you very much for sharing, appreciate that!
    I'll try to update the integration for the next version. It is crazy, game tech evolution seems to be accelerating exponentially these days, so many updates to everything, including Unity.

    Best,
    Pärtel
     
  5. XDura

    XDura

    Joined:
    Oct 27, 2016
    Posts:
    26
    Hi!, if I change a skin of the player at runtime, so all the targetTransforms are destroyed and recreated.
    How can I rebuild the puppet?
    I manually went over all muscles assigning the new TargetTransforms and did a PuppetMaster.Initiate but it doesn't work

    Thanks
     
  6. growling_egg

    growling_egg

    Joined:
    Sep 2, 2012
    Posts:
    60
    Hello! I am enjoying PuppetMaster, and read somewhere that there's an integration in the works for Opsive Ultimate Character Controller? I'm making a fighting game and if I could use FIK, PM, and UCC all at once it would be so cool! Thanks!
     
    tcmeric and Deckard_89 like this.
  7. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,968
    Hey,
    The best way to have multiple skins per character would be to just have multiple SkinnedMeshRenderers that use the same rig. Switching them would be easy. If the bone hierarchies don't match, then you can't share the PuppetMaster rig, you should have a puppet rig for each skin and instantiate the one you wish to use.

    Hey,
    Yes, it has been delayed for a while now for other priorities, but I'll pick it up again since you asked :).

    Cheers,
    Pärtel
     
  8. growling_egg

    growling_egg

    Joined:
    Sep 2, 2012
    Posts:
    60
    You're the man! I appreciate it very much. I know there's at least a handful of us out there for whom this would be the secret sauce to some really fun stuff.

    Thanks again!
     
  9. jfonz001

    jfonz001

    Joined:
    Jul 19, 2017
    Posts:
    13
    UPDATE:
    I think I figured it out. I had to give my Player controller a rigidbody and set the animation controller to this:

    Apply Root Motion: Unchecked
    Update Mode: Animate Physics
    Culling Mode: Always animate

    There is still some slight stuttering, probably just due to my awful walking animations and whatnot. My plan is to disable the puppet until I need it anyway.

    I do notice though that if I disable the puppet master and then re-enable it, my character's arms seem to fly back to their initial position when the scene started. Kinematic works fine though. Any idea why that might be? Thanks.

    Hey Partel,

    I am having trouble with my player "stuttering" while moving. I am using Aron's A* Pathfinding to move my characters. I have stripped down my player to pretty much just the model, puppet, and controller (no behaviors). In the stripped down version it seems to be smooth, so I think it may be something I am doing...that being said I then took my stuttering player (the full version) and stripped out all but the essential components and I am still experiencing the stutter. The scripts remaining on the player after this shouldn't be having any impact and at that point both versions of the player are using the same methods to move across the world.

    I made a video to help explain. The stuttering doesn't seem as bad here but if you notice, the unit closer to the camera is stuttering while the far (stripped down) unit is much smoother. Please ignore the error messages you might notice at the bottom, those are in regards to some missing components that are in my test scene and are unrelated to movement (just saving, loading, scene management etc.)



    Both units have a box collider on their controller. All colliders (the box and the puppet colliders) are set to "Player" and should not collide with eachother.

    I also see that the feet are dragging in both cases, but I think that is a separate issue as the dragging feet doesn't seem to be slowing down or causing the stuttering in the stripped down unit.
    Thank you
     
    Last edited: Jun 1, 2019
  10. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,968
    Hey,
    If there is stuttering only noticeable from a camera view point, it is because the motion of the camera and the motion of the puppet are out of sync. If your camera is updated in LateUpdate, make sure to add your camera updating script to a higher value than PuppetMaster.cs has in the Script Execution Order. Then also enable Interpolation on all the ragdoll Rigidbodies. Also make sure the character controller rigidbody is set to interpolate if you have it.

    Best,
    Pärtel
     
  11. gliealonso

    gliealonso

    Joined:
    Oct 21, 2018
    Posts:
    16
    Hello there,

    I started using the new PuppetMaster, and I noticed that my characters now stay a about 2 meters floating on the air, and I even tried to recreate the from scratch, and the issue still happpened, such as the image below:
    upload_2019-6-9_21-15-21.png

    And I also noticed this message that I didn't understand:
    upload_2019-6-9_21-16-46.png

    Is this happening with anyone else?

    Warmest regards,
    Gabriel.
     
  12. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,968
    Hey,
    Haven't seen this problem before. Any chance you could send me a repro or some instructions to reproduce the issue?

    Best,
    Pärtel
     
  13. jfonz001

    jfonz001

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

    I'm hitting this error when equipping a prop to my characters.

    https://imgur.com/a/Q0PImec

    This only happens if I try and equip the prop as soon as I hit play. If I use a coroutine to wait a few seconds before actually equipping the prop I do not get this error, so I'm wondering if it's a race-case sort of thing.

    I added some values to your debug message to try and see what is going on. As you can see the positions between the two are just slightly off. I'm wondering if it's because I am not having the unit "pick up" them items, but instead am instantiating a new clone of a prefab and then immediately equipping the prop to the prop root. Again, seems to work fine if I wait a few seconds (or even equip the prop normally mid-game). It just seems to happen if equipping right when the game starts and I'm wondering if maybe my scripts are running before your scripts are ready?

    Thanks

    Edit: I just wanted to add that I have basically applied a band-aid coroutine that waits a few seconds before equipping items after I run the game in the editor. I just wait one second, then continue on, and I don't hit this error and the prop is equipped just fine. I am pretty sure that I am equipping the prop "too soon", before something in puppet master is ready, perhaps. Any clue what that might be?
     
    Last edited: Jun 15, 2019
  14. gliealonso

    gliealonso

    Joined:
    Oct 21, 2018
    Posts:
    16

    Hi Partel,

    So I even tried creating a new project and reinstalling Final IK and the newest PuppetMaster.

    What I do is, I create a full body biped ik, then use the ragdoll creator, then create the puppetmaster, and that is it. It used to work perfectly before, but now my character just suddenly goes up 2 meters above the air.

    Looking forward to hearing from you.
    Warmest regards,
    Gabriel.
     
  15. jfonz001

    jfonz001

    Joined:
    Jul 19, 2017
    Posts:
    13
    Hey I'm no expert by any means, but that warning message in your screen shot is basically saying that when you create the Puppet it will separate the instance you are working on from it's prefab. So basically you just have to make a new prefab.

    For your issue, I would check and make sure that all elements of your character (the mesh, the armature, the puppet, the controller) are all set to the same position. You can also make sure that the ragdoll or puppetmaster colliders and the character controller colliders are playing nice and not set to collide with each other. Maybe they are pushing each other around?
     
  16. gliealonso

    gliealonso

    Joined:
    Oct 21, 2018
    Posts:
    16
    Thanks for your reply, JFonz.

    The mesh, armature and puppet all seem fine, it was working before, and I did make the colliders not collider with each other.

    Not sure why this is happening now, but I am in no hurry to fix it though hehe

    Thanks for your reply once again,
    Gabriel.
     
  17. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,968
    Hey, thanks for sending me the model, I just replied to your email.

    Best,
    Pärtel
     
    gliealonso likes this.
  18. BenWoodford

    BenWoodford

    Joined:
    Sep 29, 2013
    Posts:
    77
    Started playing with this today but having a peculiar issue - when using Frozen after the kill time the rig does this weird thing where it rotates to be semi-upright but with all the bone positions it had on the floor. Like it's been frozen solid and picked up. It seems like it's setting it back to the origin of the parent maybe?
     
  19. gliealonso

    gliealonso

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

    I hope you are well.

    Could you please help me with an issue with the Prop Master Melee?

    On the weapon prop, it needs a RigidBody, and I am using that rigid body to get collisions and velocity speed, however when I start the game, the rigid body is destroyed
    upload_2019-6-24_20-12-30.png
    upload_2019-6-24_20-13-14.png
    upload_2019-6-24_20-13-59.png

    Do you know what could be the issue?

    Many thanks!
    Gabriel.
     

    Attached Files:

  20. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,968
    Hey,
    I haven't seen this issue before. Can you please let me know how I could reproduce this issue in one of the demo scenes maybe or send me a repro that I could take a look at?

    Hey,
    The new prop system needs to destroy the rigidbody when the prop is attached to the ragdoll. That is for performance reasons, as the prop muscle already has a rigidbody. It adds the rigidbody back when the prop is dropped.
    So if you have references to the prop rigidbody in your own scripts, change them to this:

    Code (CSharp):
    1. public Rigidbody rigidbody {
    2. get {
    3. if (_rigidbody == null) _rigidbody = GetComponent<Rigidbody>();
    4. return _r;
    5. }
    6. }
    7. private Rigidbody _rigidbody;
    Best,
    Pärtel
     
  21. jfonz001

    jfonz001

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

    EDIT: I think I can do this by playing with Collision Resistance, but any other input is much appreciated, especially on how to make my player's sword less "floppy", life a wiffle ball bat.

    I'm working on Melee combat. When my attacker swings at his target he doesn't seem to be able to transfer the force of the blow completely to the target. The target puppet flinches a little, but the attacker's weapon will glance off. If the attacker is standing too close and his arms also hit the target, it's as if the attacker is crashing against a wall and he will sort of crumble to the ground.

    Occasionally, I can angle my attacker just right to where his weapon follows completely through most of the animation and the target is slammed to the ground by the force of the blow. This is more what I'm looking for.

    Is there some sort of settings for making certain animations "more rigid"?

    I am only using the Puppet Behavior with no animations on fall. If the puppet is hit hard enough they will go down.
     
    Last edited: Jul 2, 2019
  22. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,968
    Hey,
    First, make sure the layer of the prop is included in BehaviourPuppet's "Collision Layers".
    Also increasing the mass of the prop helps.

    It will probably not be enough punch still, so you might need to make use of the Boosters like in the Melee demo. Boosters give temporary immunity and/or impulse magnification (damaging other puppets more) to the puppet.
    Declare a
    Code (CSharp):
    1. public Booster booster;
    and fill it in in the editor. Set Groups to Prop and Hand, Immunity to maybe 0.5f and Impulse Mlp to something like 5.
    When you trigger the attack animation, call
    Code (CSharp):
    1. booster.Boost(behaviourPuppet);
    .
    The duration of the boosting effect is defined by "Boost Falloff" in BehaviourPuppet.

    Best,
    Pärtel
     
  23. kvachanpavel_unity

    kvachanpavel_unity

    Joined:
    Jul 6, 2019
    Posts:
    1
    Hi Partel:
    I bought and now try to combine the puppet master and final ik and ran into a problem. When I change the position of the effector bone final ik, the remaining bones of the character are pulled to the starting position. Also in the puppet master I set the Pin Weight to 1 and I basically lost all the physicality of the character. I would like to get a character's behavior like that of Clumsy Ninja, when we lift the character above the ground for some kind of limb. I looked at all the examples (including Mapping To Ragdoll), but could not find a solution. Maybe there are some ideas on how to do this?
     

    Attached Files:

  24. borkbork

    borkbork

    Joined:
    Jul 5, 2014
    Posts:
    45
    Hi Partel, kudos for the excellent work. I am working on integrating PM with Ootii's MC - I found an update to your integration package on this forum "Ootid's Motion Controller v2.73 (Unity 5.5.0)". Just wondering if this forum is the best place to find these kinds of things / if this is the most recent package?
     
  25. borkbork

    borkbork

    Joined:
    Jul 5, 2014
    Posts:
    45
    Curious, is it possible to dismember a PM rag doll?
     
  26. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,968
    Hey,
    In FBBIK, if you set "Pull" weight to 0 for all the limbs except for the one that you pull from, you will be able to drag the character as far as you like.. But that's not how you do stuff like pulling that ninja by its hand. To drag a puppet physically, add a FixedJoint between the hand rigidbody and a kinematic rigidbody, then set pin weight to 0 in PuppetMaster or if using BehaviourPuppet, call behaviourPuppet.SetState(BehaviourPuppet.State.Unpinned); and set behaviourPuppet.canGetUp to false until the hand is released. Then it will be pretty much like the "Hanging" demo in PuppetMaster.

    Hey,
    I update the integration packages every time I push a new version, but 3rd party publishers update their stuff quite often sometimes breaking the integration. I don't get notified about those updates unless one of you guys writes to me here so I also reply here with a solution. I should make a page on the website with all the patches and updates easier to find, I'll figure something out ASAP..

    Hey,
    Yes, please check out the "Removing Muscles" demo. The next version will have a new much more efficient and performant API for dismemberment, that doesn't remove muscles, which is a very slow and GC allocating thing to do. Instead, it will basically just set joint X/Y/ZMotion to Free, that costs close to nothing.
    PM doesn't have a tool for cutting skinned mesh though.

    Cheers,
    Pärtel
     
  27. FiveFingerStudios

    FiveFingerStudios

    Joined:
    Apr 22, 2016
    Posts:
    380
    I’m currently using Final IK and UMA 2.7 and I’m looking to possibly integrate puppet master for mele combat with the player.

    All of my characters share the same skeleton. I have no idea how puppet master works so I’m just throwing this out there.

    Is it possible to have 2-3 puppets in my scene and swap them to NPCs as they get close to player? I’m asking because I pool my characters and just rebuild them on demand as they get killed and I don’t want to each one to have their own puppet when not close to the player.
     
  28. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,968
    Hey,
    Yes, you could set them up with PuppetMaster (current UMA integration is broken due to UMA update, but you can find instructions from this post by another user).

    You can keep the PuppetMaster components in Disabled mode normally, then switch them to Active mode when they get near to the player.

    Best,
    Pärtel
     
    hopeful likes this.
  29. khailDev

    khailDev

    Joined:
    Feb 6, 2018
    Posts:
    10
    hello , i'am having a problem with collision detections , it's working 85% but the rest no detection at all during the whole scene so i have to restart it , when it's not working the characters go throught the obstacles and 0 detection at all
     
  30. growling_egg

    growling_egg

    Joined:
    Sep 2, 2012
    Posts:
    60

    When you notice this happen, make a note of which obstacles they go through. Turn off play mode, go back into your scene editor, and make sure that the obstacle has a collider too. Also make sure your colliders aren't too small, and lastly, make sure that "Is Trigger" is turned off.
     
  31. khailDev

    khailDev

    Joined:
    Feb 6, 2018
    Posts:
    10
    when it happens they go through everything not only one object , in the same scene with the same obstacles , 85% works but sometime if you just reload the scene with 0 change sometimes the collision doesn't work at all during the whole level but when you reload the level it works the next time
     
  32. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,968
    Hey,
    If its not just the fixed time step being too low and colliders with Discrete collision detection mode skipping colliders, there might be a script (maybe LayerSetup.cs that is used in most PM demo scenes to set up project layer collisions in play mode so the demos would work without PM having to mess up your layer collision setup in editor mode) or some other script you may have that calls Physics.IgnoreLayerCollision(). If the problem happens again, please pause the scene and check the Layer Collision Matrix, see if the layers that are supposed to collide still collide.

    Best,
    Pärtel
     
  33. Utopien

    Utopien

    Joined:
    Feb 15, 2016
    Posts:
    39
    hello does puppet master can work with floating origin reposition how does it handle instant repositioning ?
     
  34. khailDev

    khailDev

    Joined:
    Feb 6, 2018
    Posts:
    10
    thank you for your answer :D , the fixed time step is as default , also i checked the layers when it happened again and everything is ok ,




    i used the third person controller with puppet master , the puppet master game object is totally off the scene but the third person controller is working fine and the player is moving normally the puppet is trying to move according to the animation but the position is off
     
  35. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,968
    Hey,
    I once made this prototype using PuppetMaster with an astronaut floating in space. It used 1:1 scale and continuous origin reposition since the sphere for the Earth was the scale of real earth, the gravity calculations were realistic and so the velocities of ragdoll rigidbodies were something like 7600 m/s. But that was continuous reposition so I basically just had to manipulate velocity. If you have snapping reposition after a certain distance, it can still be done. You'll just need to make sure do that as the first or last thing in the frame (Script Execution Order).

    Hey.. OK, when you play the scene and the bug happens, do you see any warnings or errors coming from PuppetMaster?
    If not, I can continue guessing, but it would be the quickest solution if it was possible for you to make a repo package so I could take a closer look.

    Cheers,
    Pärtel
     
    Utopien likes this.
  36. mackerbaehr

    mackerbaehr

    Joined:
    Apr 6, 2014
    Posts:
    2
    Hello
    Is it possible to export the output animation outside of unity through fbx?
     
  37. khailDev

    khailDev

    Joined:
    Feb 6, 2018
    Posts:
    10
    0 errors or warnings , the problem only happens sometimes most of the time(with the same scenes) it's working very good , what if i check at the start if the puppet is is far from the third person controller and if yes i respawn my characters ? how can i respawn the character to their original position ?
     
    Last edited: Jul 31, 2019
  38. Utopien

    Utopien

    Joined:
    Feb 15, 2016
    Posts:
    39
    thanks for your response !
     
  39. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,968
    Hey,
    I do have a WIP baking tool that can bake Final IK and also PuppetMaster to a .anim clip in Unity, works for both Humanoid and Generic rigs. I don't have an fbx export tool, but I've heard beta testers were able to export them using Unity's FBX Exporter tool or similar.

    Hey,
    It might be that your character controller script moves the character before PuppetMaster has had a chance to initiate.
    Could you see if you can add
    Code (CSharp):
    1. if (!puppetMaster.initiated) return;
    to the beginning of all methods you have that move or rotate the character to prevent that from happening?

    Best,
    Pärtel
     
  40. khailDev

    khailDev

    Joined:
    Feb 6, 2018
    Posts:
    10
    wow that solved the problem , awesome results i'am very happy with the outcome thank you very much :D
    ++ one last question XD , how can i transfer the player to another place by script , i tried transfering the third person controller but the puppet can't follow in one frame ...
    thanks :D
     
  41. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,968
    Hey, glad its fixed :)
    try calling puppetMaster.Teleport(...);
     
  42. khailDev

    khailDev

    Joined:
    Feb 6, 2018
    Posts:
    10
    Perfect everything is working like a charm , is there any specified approach for mobile devices for performence ?
     
  43. kingburrito666

    kingburrito666

    Joined:
    Jun 28, 2019
    Posts:
    2
    Is there any way you can make this work with the Physics Slot Recipe? The colliders are created on the fly and map to different DNA types.
     
  44. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    882
    Hey there @Partel-Lang,
    I just had a quick question about the future of PuppetMaster/FinalIK. Are there any plans for making use of DOTS physics in hopes of better performance, or anything along those lines? Just wondering in general where you are expecting / wanting things to go in the future for these wonderful assets.

    Keep up the great work!
    -MH
     
  45. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,968
    No specific approach really, the performance guidelines here matter both on desktop and mobile.

    Hey,
    Not unless UMA adds tools to set up a ragdoll using a humanoid avatar and the physics slot recipe data only. Currently, looking at the code, I can't find any such tool.

    Hey,
    Last I checked, Unity Physics was still in it's early infancy and needs to mature quite a lot before it could handle anything like PuppetMaster and the performance still looks bad too. I will keep a close eye on it though...

    About the future plans, there will be major improvements to blowing off body parts and to prop workflow and performance for PuppetMaster with the next version (long overdue I know, still working out some minor problems).
    After that, Final IK will receive the Baker - a tool I've been working on for some time now, that enables you to bake animation clips, both Humanoid and Generic. You can use it on animation clips, Mecanim, layers of IK on top of Mecanim, ragdolls, PuppetMaster and Timelines and it will also have some keyframe reduction options that can get you better quality for multiple times smaller memory cost than Unity's built-in keyframe reduction. That will be followed by Timeline support, animation editing and IK keyframing tools for Final IK designed for making it super easy to edit and extend your mocap libraries in Unity.

    Cheers,
    Pärtel
     
    Subliminum likes this.
  46. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    882
    I definitely understand about the new physics being premature and definitely not ready for consideration to actually using it. It was more of a general "if" kind of question, such as if Unity physics or Havok ends up being better and more performant would you be interested in utilizing them for PuppetMaster? Such as maybe a PuppetMaster2. I do also realize it is probably too early to even answer, so no worries about it, lol.

    As for the rest of the news, that is fantastic! I am always a fan of hearing about any and all performance enhancements. :D I am especially excited to hear about the dismemberment updates. I had spent a decent amount of time either last year or the year before trying to find something that was not a complete performance hog and when I saw PuppetMaster had it, I ended up playing around with the demo scene for at least an hour. I have yet to implement it into my current project, but might reconsider it once the proposed changes come around.

    Thanks for the reply, and I definitely look forward and will keep my eye out for these updates!
    -MH
     
  47. flow-

    flow-

    Joined:
    Apr 19, 2015
    Posts:
    143
    Hey Partel,

    I have a question, how exactly find the Puppet Master Ragdoll Position?

    What I want to do is rotate the whole Ragdoll, the Ragdoll is in this moment Unpinned so I can't rotate the Target.

    I found out that puppetMaster.Teleport( Vector3, Quaternion, Bool ) works in this case ( Correct me if there is a cheaper way to rotate the ragdoll because calling the Teleport function every frame would be no good idea after looking at the code ).

    So option A to rotate the Ragdoll would be using Teleport, but I have to figure out the position which has to stay the same as the current ragdoll position, option B would be to just rotate the Hips but I did not figure out the correct rotation in this case because the RB is in a strange direction.

    EDIT: I found out it's the Player Gameobject who defines the position of the Ragdoll on the Teleport, well that's no option for me because this transform is relative to the hips muscle in this special case...
     
    Last edited: Aug 15, 2019
  48. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,968
    Hey,
    Yes, of course, when Unity Physics or Havok ends up being better, I will try my best to integrate. Especially if either one allows me to get rid of the dual rig structure of having a separate ragdoll and reorient joint default rotations. Currently I don't think Unity Physics even allows for joint target rotations, which is essential for active ragdoll stuff. Having open source code for Unity Physics is certainly a big plus though.

    Hey,
    You could just move the PuppetMaster gameobject, as the ragdoll is parented to it.
    For example to move/rotate around the hips:

    Code (CSharp):
    1. public static void RotateRagdoll(PuppetMaster puppetMaster, float angle) {
    2. Vector3 pelvisPos = puppetMaster.muscles[0].joint.transform.position;
    3.  
    4. puppetMaster.transform.rotation = Quaternion.AngleAxis(angle, Vector3.up) * puppetMaster.transform.rotation;
    5.  
    6. puppetMaster.transform.position += pelvisPos - puppetMaster.muscles[0].joint.transform.position;
    7.  
    8. }
    Best,
    Pärtel
     
    flow- and MostHated like this.
  49. PlayingKarrde

    PlayingKarrde

    Joined:
    Aug 19, 2013
    Posts:
    28
    I know this is several years old now but since I came across it during a Google search I thought I would reply in case anyone else is also looking for the solution.

    Essentially what I did to have the same problem was to accidentally increase the mass of the ragdoll in the ragdoll editor but many multiples (I think it ended up being like 100x haha). This basically meant my skeleton wasn't able to keep my bones on my body. I had to delete my ragdoll and start from scratch although I suppose it would be possible to fix by multiplying the number by a decimal amount (ie 0.5 to halve).

    I now have a better idea of what it would be like to go to a larger planet, and it wouldn't be pretty that's for sure.
     
  50. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,968
    Hey,
    I guess I should add a Reset Default Mass button to RagdollEditor, I'll put it down in my list, thanks!


    Guys, I will be out of town until 30th of August. Sorry about the inconvenience, please leave your questions here and I will attend to them as soon as I get back.
     
    MostHated likes this.