Search Unity

PuppetMaster - Advanced Character Physics Tool [RELEASED]

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

  1. shashkes

    shashkes

    Joined:
    Mar 16, 2017
    Posts:
    12
    I did that but still no difference. Any other ideas? upload_2017-4-20_15-5-7.png II
     
  2. hwc1935

    hwc1935

    Joined:
    Mar 8, 2016
    Posts:
    2
    Hi,

    I have been trying to use rigidbody add force on the ragdoll but it doesn't seem to work. The thing I'm trying to do is actually rather simple, just wanted the ragdoll to get flung in a direction when it dies. The add force however doesn't do anything to it and the ragdoll just falls onto the ground instead. I'm sure I am missing something but I'm not sure what. Any suggestions where I should look into to resolve this issue?
     
  3. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Hey,
    Can you package up that puppet and send it over to me so I could take a closer look?

    Hey, are you sure the puppet is unpinned when before you add force?

    This code works if you add it to the "Puppet" demo:
    Code (CSharp):
    1. public BehaviourPuppet puppet;
    2.  
    3.     public Vector3 force;
    4.  
    5.     void Update () {
    6.         if (Input.GetKeyDown(KeyCode.F)) {
    7.             puppet.SetState(BehaviourPuppet.State.Unpinned);
    8.  
    9.             foreach (Muscle m in puppet.puppetMaster.muscles) {
    10.                 m.rigidbody.AddForce(force);
    11.             }
    12.         }
    13.     }
    If you are not using BehaviourPuppet, just set puppetMaster.pinWeight to 0.

    Cheers,
    Pärtel
     
  4. eobet

    eobet

    Joined:
    May 2, 2014
    Posts:
    176
    Is this asset a good fit for achieving the natural and dynamic motions of games like Gangbeasts, Sumotori Dreams or Totally Accurate Battle Simulator?
     
  5. Nicksaccount

    Nicksaccount

    Joined:
    Jan 10, 2013
    Posts:
    22
    Hi Partel,

    I've been experimenting with this for the past few days and haven't been able to get any good results yet. I can get what I want working with Mechanim, but it's the PuppetMaster I'm struggling with.

    I'm using models and animations from Mixamo / Adobe Fuse and having issues with the feet. The mixamo models have an extra bone in the ankle and I can't work out how to map this correctly in PuppetMaster.

    mixamo_skeleton.png

    Every attempt looks like they've broken their ankles when walking. I've tried ignoring the rest of the foot and using the ankle for the PuppetMaster foot collider, but the joints never seem to be in the right place, or the right way around. This would cause issues anyway in future as it's not the bottom of the foot. I need to somehow move the joints around freeform, but can't work out how to do this.

    The second issue I've bene having is one of realism. The Puppet demo is a very good example of how being hit by a tennis ball should be, but even if I copy the exact values for the Puppet behaviour and the PuppetMaster component, my character tends to just slide back rather than fall down, or falls backwards when hit in the lower leg, instead of the expected forwards.

    Are there (or do you know of) any tutorials on how to setup a model with Mixamo from scratch and work relatively realistically?

    Thanks!
     
  6. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Hey,
    It doesn't have a sets those kinds of simulation up for you automatically, but I cant think of a reason those types of simulations could not be achieved with PM.

    Hey,
    Is it the orientation of the ankle bone that does not allow you to align the collider with the ground and that collider gets stuck in the ground?
    If that is the case, remove the collider from the ankle, create a new child gameobject (on the same layer) and add the collider to that. That will work as a Compound Collider and you are free to move/rotate that gameobject as you please.

    About the other issue, if the character slides back, it's probably that the ball is on a layer that collides with the character controller, so the ball might hit the character controller's capsule, not the muscles of the puppet. Make sure collisions are ignored between the ball's layer and the character controller's layer in the Layer Collision Matrix.

    Cheers,
    Pärtel
     
    cdfru472 likes this.
  7. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    edit: nvm
     
    Last edited: Apr 25, 2017
    Partel-Lang likes this.
  8. shawnblais

    shawnblais

    Joined:
    Oct 11, 2012
    Posts:
    214
    I feel like I'm missing something... what's the absolute simplest way to explode a character, switching to ragdoll as he flies through the air? I've tried switching State to DEAD, and applying explosion force to all the Rigidbodies, but there seems to be no effect.

    [EDIT - Figured it out, just needed more power! Also, helps if you just target one of the limbs and blast the hell out of it :) ]

    http://treefortress.com/shared/2017-04-24_21-34-35.mp4
     
    Last edited: Apr 25, 2017
    Partel-Lang likes this.
  9. arubaru

    arubaru

    Joined:
    Mar 24, 2017
    Posts:
    9
    Hi partel, first of all congratulations for the great asset you have made.

    I'm writing here because i've encountered a problem while using it that i don't know how to solve.

    In my scene, in certain point i have to reset the position of the character, to do it i'm calling the reset method in behaviourPuppet but in doing so the puppet part of the character resets correctly but the target does not, because i previously lowered the pinWeight.

    If i put the pinWeight of the muscles up to 1 again the target kinda flies to the puppet but i need it to teleport in an instant not fly through the scene to the reset position.

    Any ideas on how to aproach this?
     
  10. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Hey,
    Not sure whats going on there exactly, but it should help if you immediatelly after calling Reset started a coroutine that waits for the next FixedUpdate and moves all the muscles to their targets:

    Code (CSharp):
    1. private IEnumerator OnReset() {
    2.             yield return new WaitForFixedUpdate();
    3.             foreach (Muscle m in puppetMaster.muscles) m.MoveToTarget();
    4.         }
    Cheers,
    Pärtel
     
  11. arubaru

    arubaru

    Joined:
    Mar 24, 2017
    Posts:
    9
    Hi, i tried that and it kinda improved but this is still happening:



    The character falls as it should but when it hit the collider that makes it reset the position, instead of the teleport effect that i'm expecting it goes "fliying" to the reset position.
     
  12. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    401
    Partel,

    I'm wondering if something has changed with the latest version of PuppetMaster when extra force is applied to the muscles of an unpinned puppet in order to magnify a prop collision . You have a line in your release notes that says " Animated Momentum will be transferred to the rigidbodies when switching from Kinematic to active mode" and I'm just wondering if this may have changed things somewhat.

    Here is an example of code that I use to cause a puppet to have a magnified collision effect from another puppet. For some reason, I'm not getting the same effect that I used to. Upon collision using void OnCollisionImpulse(MuscleCollision m, float impulse), I call this Coroutine. I immediately set the puppet to an unpinned state, calculate a random force, pause for a half second to give the puppet time to fully ragdoll and then apply that force to the array of muscles on the PuppetMaster. I appreciate any thoughts you might have.

    Code (CSharp):
    1.  IEnumerator ApplyExtraForce()
    2.     {
    3.         petBehaviorPuppet.SetState(BehaviourPuppet.State.Unpinned);
    4.  
    5.         float forwardAmount = Random.Range(forwardForceMin, forwardForceMax);
    6.         float upwardsAmount = Random.Range(upwardsForceMin, upwardsForceMax);
    7.         Vector3 force = (transform.forward * forwardAmount) + (transform.up * upwardsAmount);
    8.  
    9.         Debug.Log("Kick" + "  " + force);
    10.         yield return new WaitForSeconds(.5f);
    11.  
    12.         foreach (Muscle m in petBehaviorPuppet.puppetMaster.muscles)
    13.         {
    14.             m.rigidbody.AddForce(force, ForceMode.Impulse);
    15.         }
    16.     }
    Allan
     
  13. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Hey,
    I will make some experiments, hold on...

    Hey,
    If your puppet in Kinematic mode when the collision happens? Or is BehaviourPuppet's "Normal Mode" set to Kinematic? Please let me know if commenting out lines 149 and 150 (setting rigidbody velocity and angularVelocity) in PuppetMasterModes.cs fixes it?

    Best,
    Pärtel
     
  14. Deleted User

    Deleted User

    Guest

    So this is now at 0.61. What exactly is missing or what are you working on til final release or could I use this as of today without many bugs etc.

    And is this complicated like Final IK or are there some presets (like drag and drop file -> ragdoll implemented) and can I modify settings within the Unity Editor? I am not a pro programmer and I think many would buy this asset when people like me (who can barely code) could make use of this asset.
     
  15. rossdp

    rossdp

    Joined:
    Apr 28, 2017
    Posts:
    19
    Hi Pärtel,

    First of all, thanks so much for the amazing work you've done with Puppet Master and Final IK. I have purchased both packages and am trying to learn how to use them. I've gone through a lot of tutorials and read a lot of this thread but I'm still having problems, I am sure I'm doing something stupid and hope you can point me in the right direction.

    [EDIT: Removed the problem, it was indeed my own problem. I wasn't waiting for the UMA to be completely created. Apparently it takes a few ticks before it's usable, and in those first ticks it reports Animator.isHuman=false which short circuits Final IK. Now I'm waiting, and the FBBIK is being successfully created.]
     
    Last edited: May 1, 2017
  16. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    401
    Thanks for getting back on this Partel. So far I have only been using my Puppets in Active mode. I haven't experimented yet with performance optimizations that might be realized from Unmapped or Kinematic modes. Commenting out line 149 and 150 made no difference probably because I am not switching to Kinematic mode.

    I did find the solution. It tuns out when you are trying to apply an outside force to the muscle rigidbodies, you need to make sure you set GetUpDelay in BehaviorPuppet to be greater than 0 so the puppet does not switch into GetUp state before you apply your forces. In my Coroutine, I was pausing for .5 seconds after Unpinning before applying my forces. Since GetUpDelay was set to 0, the puppet had switched to GetUp state and in GetUp state it looks like you do some messing with puppet position and some other stuff.

    I assumed that by applying forces to the muscle rigidbodies, the puppet would stay unpinned because I just hit him with some forces but during that .5 second pause, he started to Getup and the forces never had their intended effect.

    Thanks
    Allan
     
  17. Mad_Fox

    Mad_Fox

    Joined:
    May 27, 2013
    Posts:
    49
    Hi Partel, is there a quick way to scale my puppet character on runtime without breaking it?, i want to shrink or enlarge a character based on some power up, but the puppet RB dont scale well or everything brake in the process, if i scale the character prefab before instantiating it works perfect. Thanks!
     
  18. petershtif

    petershtif

    Joined:
    Mar 1, 2014
    Posts:
    4
    Hi Partel, we just bought all of your assets as they looks amazing and can be useful for some of our prototype ideas. Anyway I went with your tutorials and set up the character with Final IK and Puppet master but no matter what I do it always go to rag doll and just blows up basically without any contraints etc. And my console is spammed with NullReferenceExceptions.

    Any info on what is going on? I am using latest Unity 5.6 and a character without any animation just Final IK.

    Thanks

     
  19. rossdp

    rossdp

    Joined:
    Apr 28, 2017
    Posts:
    19
    Hi Pärtel,

    I worked out my UMA issues and now I'm having a different problem with generating PuppetMaster at runtime.

    If I use the PuppetMaster.SetUp method then there is a warning message printed to the console about "Node transform is null in FBIK chain" and no PuppetMaster component exists in the generated object.

    If I instead use PuppetMaster.SetUpTo then no such warning is printed, and a PuppetMaster component is generated. However a ton of objects are added to the top level of the hierarchy which is causing other errors. (These seem to be duplicates created by PuppetMaster).

    I've attached screen shots as well as the code I am using.

    Thanks in advance for any insight you can provide.

    SetUp results screen shot:

    - Node transform is null in FBIK chain warning message
    - Avatar Root does not contain a PuppetMaster component



    SetUpTo result screen shot:

    - Avatar Root does contain a PuppetMaster
    - There is no warning message about "Node transform null"
    - There are a huge number of objects created in the root hierarchy - clearly in the wrong place.



    My code:

    - OnCharacterCreated is called by UMAData.OnCharacterCreated (the recommended integration type for UMA + Final IK according to the UMA wiki)
    - It calls either setUpPuppetMaster or setUpPuppetMaster_SetUpTo (result of both shown above)

    Code (CSharp):
    1.  
    2. using RootMotion;
    3. using RootMotion.Dynamics;
    4. using RootMotion.FinalIK;
    5. using System;
    6. using UMA;
    7. using UnityEngine;
    8.  
    9. public class FBBIKUMA {
    10.  
    11.     // TODO move this to a better place
    12.     private static int characterControllerLayer = 8;
    13.     private static int ragdollLayer = 9;
    14.  
    15.     public static void OnCharacterCreated(UMAData data)
    16.     {
    17.         setUpRagdoll (data);
    18.  
    19.         //setUpPuppetMaster (data);
    20.         setUpPuppetMaster_SetUpTo (data);
    21.     }
    22.  
    23.     private static void setUpPuppetMaster(UMAData data)
    24.     {
    25.         var go = data.gameObject;
    26.  
    27.         Debug.Log ("Setting up " + go.name + " puppet using SetUp");
    28.  
    29.         PuppetMaster.SetUp (go.transform, characterControllerLayer, ragdollLayer);
    30.     }
    31.  
    32.     private static void setUpPuppetMaster_SetUpTo(UMAData data)
    33.     {
    34.         var go = data.gameObject;
    35.  
    36.         Debug.Log ("Setting up " + go.name + " puppet using SetUpTo");
    37.  
    38.         var pm = go.AddComponent<PuppetMaster> ();
    39.         pm.SetUpTo(go.transform, characterControllerLayer, ragdollLayer);
    40.     }
    41.  
    42.     private static void setUpRagdoll(UMAData data)
    43.     {
    44.         var go = data.gameObject;
    45.  
    46.         Debug.Log ("Setting up " + go.name + " ragdoll");
    47.  
    48.         if (!data.animator.isHuman)
    49.             throw new Exception ("Animator.isHuman is false");
    50.  
    51.         // Auto-detect UMA bone references
    52.         var references = new BipedReferences();
    53.         BipedReferences.AutoDetectReferences (ref references, go.transform, BipedReferences.AutoDetectParams.Default);
    54.  
    55.         // Add and configure FBBIK component
    56.         var ik = go.AddComponent<FullBodyBipedIK> ();
    57.  
    58.         ik.SetReferences(references, null);  // transform ?? gameObject.transform ??
    59.         ik.solver.SetLimbOrientations (BipedLimbOrientations.UMA);
    60.  
    61.         // Create Ragdoll
    62.         var ragdollReferences = BipedRagdollReferences.FromBipedReferences(references);
    63.  
    64.         if (! ragdollReferences.IsValid())
    65.             throw new Exception("Ragdoll References are not valid");
    66.  
    67.         // How would you like your ragdoll?
    68.         BipedRagdollCreator.Options options = BipedRagdollCreator.AutodetectOptions(ragdollReferences);
    69.  
    70.         // Edit options here if you need to
    71.         //options.headCollider = RagdollCreator.ColliderType.Box;
    72.         //options.weight *= 2f;
    73.         //options.joints = RagdollCreator.JointType.Character;
    74.  
    75.         BipedRagdollCreator.Create(ragdollReferences, options);
    76.     }
    77. }
    78.  
     
  20. FergJoe

    FergJoe

    Joined:
    Dec 28, 2016
    Posts:
    9
    Hi Pärtel!

    First - WOW! This is an incredible piece of work. I'm having a blast just adding it to my AI characters and seeing how I can get them to react to the environment around them (or anything I throw at them!)

    Since you developed VRIK as well, I was wondering you had any information to share on using PuppetMaster in VR? My brother and I have a Vive, and use VRTK as our scripting framework. We've been experimenting with both PuppetMaster and VRIK, but I wanted to see if you had any tips / settings that you've found helpful?

    Again, thanks for a solid piece of software (in beta even) - and for your time!
     
  21. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Hey,
    It is completely usable today, there is no "final release" really, just like FIK it has been in development for some 5 years already and will be continuously updated and improved for years to come.

    It is much more complicated than FIK actually, being a dynamics solution, it has the additional factor of time and that makes everything more complicated by nature. I would not recommend it to users without any coding experience. I mean you'll get system working basically, but to make it do exactly what you need it to do in your particular game, probably takes some coding, using the PuppetMaster API.

    Hey,
    Yes, please see the "Scaling" demo (only in the latest PM).

    Hey,
    As the error says, there is a problem with the joints. Go to the joint on "spine_01" and make sure it's "Secondary Axis" does not match it's "Axis", just use another orthogonal axis for the secondary axis. Let me know if there are any other problems.

    Hey,
    Have you seen the "UMA2" integration package under Plugins/RootMotion/PuppetMaster/_Integration? It has an example of setting up PM with UMA.
    To be safe, IK should be added to the character after creating the puppet.

    Thanks!
    I am planning to make some VR demos for the next version of PM, don't have an ETA for it yet.
    Ran a little errand few months back, helped the guys at Owlchemy set up Rick and Morty with PuppetMaster, so there definitely are uses for it in VR. ;) But what exactly are you trying to achieve with VRIK/PM?


    Cheers,
    Pärtel
     
  22. rossdp

    rossdp

    Joined:
    Apr 28, 2017
    Posts:
    19
    I hadn't seen it, but I will definitely take a look. Thanks! :)
     
  23. FergJoe

    FergJoe

    Joined:
    Dec 28, 2016
    Posts:
    9
    Nice! Cy and the gang down at Owlchemy are an amazing group! Now that I know PM is used in Rick & Morty VR, I'll have to look more carefully next time I play! I'll look forward to those VR demos in the future!

    My brother and I are hoping that a combination of VRIK and PM can help make VR melee combat more realistic and fun. Having dozens of animations and a complex AI tree is fine, but we hope to be able to produce more realistic feedback.

    I did run into one question this evening: I finished an AI character in a "lab" project, made him a prefab, and exported him for a trial run in the "real" project. When I import the character, the ragdoll goes berserk, acting unpredicatably / bouncing / flying around the level. The "completed project" has the full FinalIK and PM packages installed, and I checked layers for conflicts / set Ground / etc. The AI uses a NavMeshAgent and behavior tree - no controller or root motion, if that makes a difference. The original still works perfectly in his old lab project.

    The only way to correct the issue I've found is to make a new ragdoll and puppetmaster on the model. It's easy enough to do, but have I missed a step somewhere?

    Thanks again!
    Joe
     
  24. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Hey, can you send me the package you exported so I could take a closer look?

    Cheers,
    Pärtel
     
  25. montyfi

    montyfi

    Joined:
    Aug 3, 2012
    Posts:
    540
    Hi @Partel-Lang, I have created a ragdoll on generic skeleton, everything works fine except from time to time after applying the force, unpinning and pinning back hand joints go crazy and ragdoll hand colliders cannot return to the original position. They start move chaotically, rotating at 90 degree to the attached bone. Any idea how to fix that?
     
  26. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Hey, no idea, can you send me that rig so I could take a closer look?
    Pärtel
     
    montyfi likes this.
  27. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    401
    Partel,

    I finally tracked down some really nasty bugs that have been eluding me for months and I figured out how to replicate them consistently in your melee demo. :)

    Have the Third Person Puppet pick up the prop on the ground and then SetState of behaviorPuppet to unpinned within OnCollisionImpulse and you will receive the following errors:

    How to replicate:
    In your Melee demo,
    1. Add code to UserControlThirdPerson.cs so you can Unpin the character when the OnCollisionImpulse event is called but still pickup the prop.
    2. Play the game and have the character pickup the prop.
    3. As soon as the character collides with any object in the collision layers, you will receive the following errors.

    As you may recall, I was seeing Error 1 when doing prop drops but it wasn't consistent and I was unable to track it down. It wasn't until I started trying to unpin due to collisions with arrow props that the error occurred every time. My arrow props are isKinematic and calculated with math instead of physics forces so the collision impact/impulse is negligible and thus I want to unpin the puppet manually upon collision with muscles using OnCollisionImpulse.

    Here is the code I added to UserControlThirdPerson.cs. I placed //Added comments on the lines I added. I'll just paste the top section of code since that's all that's needed.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using RootMotion.Dynamics;  //Added
    4.  
    5. namespace RootMotion.Demos {
    6.  
    7.     /// <summary>
    8.     /// User input for a third person character controller.
    9.     /// </summary>
    10.     public class UserControlThirdPerson : MonoBehaviour {
    11.  
    12.         // Input state
    13.         public struct State {
    14.             public Vector3 move;
    15.             public Vector3 lookPos;
    16.             public bool crouch;
    17.             public bool jump;
    18.             public int actionIndex;
    19.         }
    20.  
    21.         public bool walkByDefault;        // toggle for walking state
    22.         public bool canCrouch = true;
    23.         public bool canJump = true;
    24.  
    25.         public State state = new State();            // The current state of the user input
    26.  
    27.         protected Transform cam;                    // A reference to the main camera in the scenes transform
    28.         BehaviourPuppet behaviorPuppet; //Added
    29.  
    30.         void Start () {
    31.             // get the transform of the main camera
    32.             cam = Camera.main.transform;
    33.             //Added
    34.             behaviorPuppet = transform.root.GetComponentInChildren<BehaviourPuppet>();
    35.             //Added
    36.             behaviorPuppet.OnCollisionImpulse += OnCollisionImpulse;
    37.         }
    38.  
    39.         //Added
    40.         void OnCollisionImpulse(MuscleCollision m, float impulse)
    41.         {
    42.             int layer = m.collision.gameObject.layer;
    43.             if (layer != 1) //prop Trigger layer
    44.             {
    45.                 behaviorPuppet.SetState(BehaviourPuppet.State.Unpinned);
    46.             }
    47.         }
    Error 1:
    Destroying components immediately is not permitted during physics trigger/contact, animation event callbacks or OnValidate. You must use Destroy instead.
    UnityEngine.Object:DestroyImmediate(Object)
    RootMotion.Dynamics.PuppetMaster:RemoveMuscleRecursive(ConfigurableJoint, Boolean, Boolean, MuscleRemoveMode) (at Assets/Plugins/RootMotion/PuppetMaster/Scripts/PuppetMasterHierarchyAPI.cs:142)
    RootMotion.Dynamics.BehaviourBase:RemoveMusclesOfGroup(Group) (at Assets/Plugins/RootMotion/PuppetMaster/Scripts/Behaviours/BehaviourBase.cs:357)
    RootMotion.Dynamics.BehaviourPuppet:SetState(State) (at Assets/Plugins/RootMotion/PuppetMaster/Scripts/Behaviours/BehaviourPuppetStateSwitching.cs:69)
    RootMotion.Demos.UserControlThirdPerson:OnCollisionImpulse(MuscleCollision, Single) (at Assets/Plugins/RootMotion/Shared Demo Assets/Scripts/Character Controllers/UserControlThirdPerson.cs:44)
    RootMotion.Dynamics.BehaviourPuppet:OnMuscleCollisionBehaviour(MuscleCollision) (at Assets/Plugins/RootMotion/PuppetMaster/Scripts/Behaviours/BehaviourPuppetDamage.cs:46)
    RootMotion.Dynamics.BehaviourBase:OnMuscleCollision(MuscleCollision) (at Assets/Plugins/RootMotion/PuppetMaster/Scripts/Behaviours/BehaviourBase.cs:143)
    RootMotion.Dynamics.MuscleCollisionBroadcaster:OnCollisionEnter(Collision) (at Assets/Plugins/RootMotion/PuppetMaster/Scripts/MuscleCollisionBroadcaster.cs:94)

    Error 2:
    IndexOutOfRangeException: Array index is out of range.
    RootMotion.Dynamics.BehaviourPuppet.GetImpulse (MuscleCollision m, System.Single& layerThreshold) (at Assets/Plugins/RootMotion/PuppetMaster/Scripts/Behaviours/BehaviourPuppetDamage.cs:79)
    RootMotion.Dynamics.BehaviourPuppet.OnMuscleCollisionBehaviour (MuscleCollision m) (at Assets/Plugins/RootMotion/PuppetMaster/Scripts/Behaviours/BehaviourPuppetDamage.cs:43)
    RootMotion.Dynamics.BehaviourBase.OnMuscleCollision (MuscleCollision collision) (at Assets/Plugins/RootMotion/PuppetMaster/Scripts/Behaviours/BehaviourBase.cs:143)
    RootMotion.Dynamics.MuscleCollisionBroadcaster.OnCollisionStay (UnityEngine.Collision collision) (at Assets/Plugins/RootMotion/PuppetMaster/Scripts/MuscleCollisionBroadcaster.cs:104)

    Thanks
    Allan
     
    Last edited: May 7, 2017
  28. matteumayo

    matteumayo

    Joined:
    Jul 25, 2016
    Posts:
    170
    Hello,

    I'm having a confusing issue. I'm trying to use VRIK with an enemy puppet, set to Active mode. I made a custom script that simply turns on and off the positionWeight of the left and right arms when an object comes near.

    However, even though pin weight for upperbody is set to 0.5 as you recommend, when VRIK's positionWeight is set to 1 for an arm, the arm instantly moves there, with no puppetMaster functionality at all.

    Strangely, however, if I click (select) the PuppetMaster object in the editor hierarchy, suddenly it works properly, and the puppet moves itself properly to the IK target, rather than instantly teleporting there.

    It seems the puppet again acts as though it's not active after getting up from knock down, as well, even though the Puppet behavior is set to active.

    It's as though mapping weight is set to 0 on every muscle, but even after changing mapping weight minimums, there is no difference until I click on the PuppetMaster object...

    I feel like this is hard to explain in words, so here's a gif:



    Any ideas?

    Thanks!
    Matt
     
    Last edited: May 7, 2017
  29. arubaru

    arubaru

    Joined:
    Mar 24, 2017
    Posts:
    9

    Finally managed to solve it by implementing a coroutine that disables the gameobject for a frame and reactivates it again, but that dosnt feels like the "correct" way to do it.

    The problem was that i was making pinWeight = 1 (it was 0.25 previously) and the model flyed to the puppet even when i was reseting the position.

    Any thoughts?
     
  30. TPierce89

    TPierce89

    Joined:
    Aug 18, 2013
    Posts:
    3
    Ive been working through tutorials all afternoon and I cant get my characters to work. I set them up as ragdolls, but before I even add any behaviors, their stomach gets stuck in place. Ive tried adding behaviors. Ive tried replacing the character in the example with mine. Nothing seems to work. What am I missing? Heres a gif...

     
  31. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Hey, thanks for the report!
    So the problem is behaviourPuppet.SetState being called from OnCollisionEnter/Stay (that's where OnCollisionImpulse comes from) and that resulting in BehaviourPuppet dropping props and PuppetMaster destroying the joint and Unity apparently doesn't like calling Destroy at that time.
    Please import this patch to fix it. Make sure not to remove any muscles in collision functions for now, I'll find a way to safeguard from that.

    Hey,
    Are you also using BehaviourPuppet on that and if so, what is it's "Normal Mode"?

    Hey,
    Got me thinking, are you using BehaviourFall and is that behaviour active when you reset?

    Hey,
    Any errors/warnings in the Console from PuppetMaster? Could you send me that rig in a scene as a unitypackage?

    Best,
    Pärtel
     
  32. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    401
    Patel,

    Thanks for that. I'll check out the patch. Unfortunately I think I found another bug with OnCollisionImpulse.

    For performace reasons, my arrows are isKinematic Rigidbody colliders. I use math to calculate trajectory.
    My other props like shield and sword are regular muscle props attached to PuppetMaster muscles. I have both arrows and my other props on the same physics layer and that layer is assigned to Collision Layers in Behavior Puppet.

    If I spawn a Puppet from a pool, OnCollisionImpulse will not send events when collisions occur with my arrows. If I don't spawn the puppet and it is already in the scene when I press play, OnCollisionImpulse will send events for both my arrows and all other muscle based props. So I know I have the layering setup correctly because everything works when the puppet is in the scene prior to playing.

    So the issue is OnCollisionImpulse is acting differently when a puppet is spawned vs. already active in the scene. The arrows are also spawned but I don't think that is an issue. It likely has something to do with when the OnCollisionImpulse event is regiistered...but that's just a guess.

    I am also using puppet.Reset upon spawning just in case that was an issue. It did not make a difference.
    I can only think of 2 differences between my arrow props and my Sword and Shield props. The arrows are not attached to the PuppetMaster muscles when they collide and they are isKinematic Rigidbody colliders where the sword and shield are attached to the ragdoll puppet and they are muscles/ not isKinematic.

    I should also mention that I'm not doing anything unusual with my spawning. I use PoolManager from the Asset store. Which means I am pre-loading Puppet enemies who are disabled in scene and then when I spawn them, they are enabled.

    I can probably setup a test case in one of your demo scenes as I get time if you need it.

    Thanks
    Allan.
     
    Last edited: May 9, 2017
  33. matteumayo

    matteumayo

    Joined:
    Jul 25, 2016
    Posts:
    170
    The puppet does have behaviour Puppet's mode on Active. I found the issue was due to the experimental "PuppetControllerBasic" script you attached earlier, to help with melee combat - when disabled, behavior is normal. My bad!

    I'd also like to mention a bug with that same PuppetControllerBasic script: When using props, equipped in runtime, I get an indexOutOfRange error, and I couldn't really figure out how to fix it, as when I logged the index everything seemed normal. It's an error in the for loop in Update at line 62.

    Of course, I'm aware this script isn't an official addition yet, so I'll try and figure it out myself.

    Thanks,
    Matt
     
  34. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Hey,
    Can you pause the game and check let me know if MuscleCollisionBroadcaster components are to be found on the muscles of the spawned puppet?

    Hey, please import this package, updated PuppetControllerBasic to support adding/removing muscles.

    Best,
    Pärtel
     
    matteumayo likes this.
  35. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    401
    Partel,

    Yes, the spawned puppets have both the MuscleCollisionBroadcaster and the JointBreakBroadcaster installed on each muscle of the PuppetMaster ragdoll.

    Allan
     
    Last edited: May 11, 2017
  36. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Hey,
    If you comment out all 3 instances of
    Code (CSharp):
    1. if (collision.collider.transform.root == transform.root) return;
    in MuscleCollisionBroadcaster.cs, will you start getting the OnMuscleCollision calls?

    Pärtel
     
  37. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    401
    Partel,

    That did it!! Nice job! :) I commented out all 3 instances of that code in MuscleCollisionBroadcaster.cs and I now have OnCollisionImpulse collisions with spawned enemy prefabs when using my spawned isKinematic Rigidbody arrows.

    I'm only using OnCollisionEnter since I am using PuppetMasterSettings to disable Stay and Exit but I still went ahead and commented out all of it.

    Thanks again.

    Allan
     
  38. Partel-Lang

    Partel-Lang

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

    Great, but uncomment them, just make sure the arrows will not have the same root transform as the puppet. Those lines are used to make sure the puppet does not process internal collision events. It's prone to error like you saw, but it is the fastest way I could think of and speed in those functions really is the number 1 thing to consider since they might be processed tens or hundreds of times each frame for each puppet.

    Best,
    Pärtel
     
  39. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    401
    Partel,

    Ok I understand how keeping those lines will improve performance. It's still very strange that this only effects Puppets that are prefabs that are spawned and not puppets that are already in the scene. That seems like a bug in how you are registering the OnCollisionImpulse Event or possibly in how MuscleCollisionBroadcaster is working because my sword and shield collisions work fine since they are setup as regular props but of course they have MuscleCollisionBroadcaster components on them like the other puppet master muscles.

    The fact is I could handle my arrow collisions in my ArrowLogic code using OnCollisionEnter if I could figure out how to get a reference to MuscleCollision m that is provided from within OnCollisionImpulse in OnCollisionEnter from my Arrow. The muscle index is really all I need so I can determine which muscle I have collided with. Is there any way to get MuscleCollision or the muscle index when my arrows collide with the puppet muscle using OnCollisionEnter from the arrow gameobejct? I use MuscleCollision for the muscleIndex in order to determine which muscle my arrow hit so I can determine a head shot, spine shot, etc. using
    Code (CSharp):
    1. if (behaviorPuppet.puppetMaster.muscles[m.muscleIndex].props.group == Muscle.Group.Head)
    In many ways it would be cleaner for me to handle the collision logic in OnCollisionEnter on the arrow itself instead of relying on OnCollisionImpulse but I can't figure out how to get the muscleIndex.

    Thanks
    Allan
     
    Last edited: May 16, 2017
  40. arubaru

    arubaru

    Joined:
    Mar 24, 2017
    Posts:
    9
    I'm not using any behaviour, and even having it resolved i keep looking into it cause this kind of "bugs" are so satisfying when you finally solve them :)
     
  41. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Hey,
    Are you parenting all the spawned puppets and arrows to the same gameobject? Those lines just discard all collisions with objects that have the same transform.root as the puppet itself.

    You can get the muscle index of a puppet you hit if you find the MuscleCollisionBroadcaster component on the attachedRigidbody and if it's there, use broadcaster.muscleIndex. Check for layers before using GetComponent to save some performance.

    Hey,
    I thought you were using BehaviourPuppet as the issue was with calling behaviourPuppet.Reset()?

    Best,
    Pärtel
     
  42. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    401
    Partel,

    Thanks. Accessing muscleIndex from MuscleCollisionBroadcaster worked great!
    Code (CSharp):
    1. int muscle = collision.transform.GetComponent<MuscleCollisionBroadcaster>().muscleIndex;
    And yes I filter all collisions by layers.

    At first I wasn't sure what you were talking about regarding character hierarchy. But yes since I am spawning enemy puppets in using PoolManager, by default the spawned enemy puppet prefabs stay within the PoolManager hierarchy. Do you think that's the problem? Here is a pic of the PoolManager Hierarchy with spawned enemy prefab.

    My bolts/arrows are parented to the transform they collide with. They stay parented to the transform on the character until I despawn them after a few seconds. So as you can see in the pic, each arrow is parented to a puppet muscle collider/rigidbody it collided with. That way the arrows move with the character until they are despawned. I handle damage particle effects the same way. If an arrow hits the head, I can unpin the character and add some extra force so he goes flying and throw up a text dialog saying "Nice Head Shot".

    Let me know if you need anything else.

    PuppetHierarchyPrefab.PNG
     
  43. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    401
    Partel,

    I just tested it. You are right on!! If the puppet is spawned under another gameobject (like in PoolManager), OnCollisionImpulse fails when collisions occur with isKinematic rigidbody colliders like my arrows. If I spawn the enemy puppet directly into the scene root, there are no problems with OnCollisionImpulse.

    Allan
     
    Last edited: May 17, 2017
  44. arubaru

    arubaru

    Joined:
    Mar 24, 2017
    Posts:
    9

    I was, but i though the bug could be because of some weird interaction so i extracted the reset method and placed it in another script and now i have no behaviour, anyway the fliying thing happens with or without the behaviour.
     
  45. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Hey, sorry for the delay, took some time to rewrite all that reset/teleporting code.
    Please import
    Code (CSharp):
    1. https://www.dropbox.com/s/k00uj7rt8n0r6qg/PuppetMasterTeleport.unitypackage?dl=0
    to the latest PuppetMaster.

    I deprecated BehaviourPuppet.Reset as it was confusing and not usable without BehaviourPuppet.
    Please use
    Code (CSharp):
    1. PuppetMaster.Teleport(Vector3 position, Quaternion rotation, bool moveToTarget);
    Also, take a look at the new code in Respawning.cs.

    Best,
    Pärtel
     
    CoolStuntz and cdfru472 like this.
  46. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    390
    Hi Partel, I'm having difficulty getting this line to work
    broadcaster.Hit(unpin, ray.direction * force, hit.point);
    I'm trying to have a similar reaction to the puppet raycast hit demo. I think it's likely that I have missed a setting somewhere. Currently I call this line and there's very little reaction even when I raise the unpin and force numbers very high.
     
  47. arubaru

    arubaru

    Joined:
    Mar 24, 2017
    Posts:
    9
    Thx man, looks great!!!

    And here comes another question :)
    Now when my character is falling in the air with the pinWeight reduced to .25 when he is playing an animation like crouching all is good but when is playing another one in wich he stretch like a candle you could say, instead os playing the full animation, the arms start waving around but the rest of the body stil plays the animation well. And i have no clue to what is happening.
     
  48. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Hey,
    If you deactivate the BehaviourPuppet gameobject you have there and drag in the one from the Puppet Raycast Hit demo, will it work better?

    Hey,
    Could you make a video of that issue or something? Would increasing Muscle Spring improve it?

    Best,
    Pärtel
     
  49. arubaru

    arubaru

    Joined:
    Mar 24, 2017
    Posts:
    9
    I've been tweaking the muscle spring and it change things: the higher it is, the faster the arms go waving around like crazy, the slower, the less they move but still dont go into the position that they should acording to the animation.
     
  50. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Try disabling "Angular Limits" and "Internal Collisions", maybe they don't allow for the arms to reach their pose.