Search Unity

  1. We've closed the job boards. If you're looking for work, or looking to hire check out Unity Connect. You can see more information here.
    Dismiss Notice
  2. Unity 2017.3 has arrived! Read about it here.
    Dismiss Notice
  3. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

PuppetMaster - Advanced Character Physics Tool [RELEASED]

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

  1. Zrexa

    Zrexa

    Joined:
    Oct 29, 2014
    Posts:
    154
    @trappist-1 Thank, you are absolutely correct, I had forgotten to set the prefabs to Animate Physics - that was causing the jumping and crazyness. @Partel-Lang This was the problem, got it working fine now, thank you.
     
    Last edited: Dec 9, 2017
    trappist-1 likes this.
  2. montyfi

    montyfi

    Joined:
    Aug 3, 2012
    Posts:
    536
    Hi @Partel-Lang I haven't touched puppet for a long time, so maybe situation is different now: I want to control the puppet in VR, but use locomotion for legs, because otherwise legs movement looks like its owner is a drunk sailor (or I didn't find a way to move it realistically)
    Could you give an example how to achieve a realistic legs movement without legs tracking? E.g. when puppet moves legs are animated by Animator (lets say just forward/backward/sidesteps), and when doesn't move (or rotating) - by puppet master. Is that even possible?
     
  3. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,519
    Hey,
    With just PuppetMaster the only way to do this kind of procedural locomotion would to unpin the legs and use kinematic rigidbodies jointed to the feet as footstseps, but I can't really imagine that looking very good.

    If you're looking for procedural locomotion for VR, I suggest you check out VRIK of Final IK.

    Best,
    Pärtel
     
  4. montyfi

    montyfi

    Joined:
    Aug 3, 2012
    Posts:
    536
    Oops, sorry. I'm using VRIK for player, and grounder. I will send you a PM instead of polluting the wrong thread.
     
  5. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    351
    I'm having an issue where I crash into an object and reparent my puppet setup my character flies off way further than what would happen normally in the physics. I'm setting the velocity negative to put the character on the ground but it's never enough. I'm not sure what's going on, but I could add a force to the puppetmaster rigidbodies but that doesn't seem like what I should need to do because normally I only move the rigid on the character and everything works fine.

     
  6. Useless-Media

    Useless-Media

    Joined:
    Apr 19, 2015
    Posts:
    66
    Alright i capture it
    2017-12-17 01_10_54-.png 2017-12-17 01_11_30-.png

    Maybe i was really really lucky but the error was coming when i was using the UMA HumanMale character race and i used it at last a long time ago.
    I hope the log statements help you to optimize your product
     
    Last edited: Dec 17, 2017
  7. Subzeroblack68

    Subzeroblack68

    Joined:
    Apr 3, 2014
    Posts:
    13
    Ran into a small problem I havent been able to solve, but its one of those things I cant get out of my head until its figured out and im going to work so IO cant test anything out at the moment :'( ...I have been using VRIK to punch Puppetmaster AI, but I wanted to change it to react like the Puppetmaster HitReaction.

    What I want to do is have a game object connected to the controllers (sphere collider) and when it hits/touches the Puppetmaster dummy it essentially mimics the Raycastshooter.cs on the Puppet RaycastHit scene... I assume I should use OnCollisionEnter but I dont know how to go about it. I'm fairly certain it has to do with these lines of code:

    Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
    // Raycast to find a ragdoll collider
    RaycastHit hit = new RaycastHit();
    if (Physics.Raycast(ray, out hit, 100f, layers)) {
    var broadcaster = hit.collider.attachedRigidbody.GetComponent<MuscleCollisionBroadcaster>();
    if (broadcaster != null) {
    broadcaster.Hit(unpin, ray.direction * force, hit.point);




    I haven't used Puppetmaster long and still dont know how to communicate with it properly, and I have not used Raycast before so that messes me up with understanding what im reading/looking at.
     
  8. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,519
    Hey,
    How exactly are you unpinning the puppet on that collision, by setting it to Dead state or using behaviourPuppet.SetState or jut setting puppetMaster.pinWeight to 0?

    Hey,
    Thank you very much! Is the one that is on the top the very first error that was logged?

    Hey,
    You might get better results with another technique. Please import this package to check it out. I used a similar technique for setting up Rick and Morty so they could be slapped around in that VR game.

    Cheers,
    Pärtel
     
  9. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    351
    I'm using puppetMaster.behaviours[0].Activate(); To activate the falling behaviour
     
  10. Useless-Media

    Useless-Media

    Joined:
    Apr 19, 2015
    Posts:
    66
    Yes there was a log before but this was my stuff, i need to found out a value of a float while i was working on the character, but all logs what you can see on the Screenshot is yours.
     
  11. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,519
    Hey,
    Please go to BehaviourFall.cs and change the contents of
    Code (CSharp):
    1. private IEnumerator SmoothActivate()
    in line 135 to this:
    Code (CSharp):
    1. private IEnumerator SmoothActivate() {
    2.             timer = 0f;
    3.             endTriggered = false;
    4.             puppetMaster.targetAnimator.CrossFadeInFixedTime(stateName, transitionDuration, layer, fixedTime);
    5.  
    6.             foreach (Muscle m in puppetMaster.muscles) {
    7.                 m.state.pinWeightMlp = 0f;
    8.             }
    9.  
    10.             float fader = 0f;
    11.  
    12.             while (fader < 1f) {
    13.                 fader += Time.deltaTime;
    14.  
    15.                 foreach (Muscle m in puppetMaster.muscles) {
    16.                     m.state.pinWeightMlp -= Time.deltaTime;
    17.                     //m.state.muscleWeightMlp += Time.deltaTime;
    18.                     m.state.mappingWeightMlp += Time.deltaTime * blendMappingSpeed;
    19.  
    20.                     m.rigidbody.velocity = m.mappedVelocity;
    21.                     m.rigidbody.angularVelocity = m.mappedAngularVelocity;
    22.                 }
    23.  
    24.                 yield return null;
    25.             }
    26.         }
    Ok thanks! Please just change Muscle.Pin to this:
    Code (CSharp):
    1. private void Pin(float pinWeightMaster, float pinPow, float pinDistanceFalloff) {
    2.             positionOffset = targetAnimatedPosition - rigidbody.position;
    3.             if (float.IsNaN(positionOffset.x)) positionOffset = Vector3.zero;
    4.  
    5.             float w = pinWeightMaster * props.pinWeight * state.pinWeightMlp;
    6.  
    7.             if (w <= 0f) return;
    8.             w = Mathf.Pow(w, pinPow);
    9.  
    10.             Vector3 p = positionOffset / Time.fixedDeltaTime;
    11.  
    12.             Vector3 force = -rigidbody.velocity + targetVelocity + p;
    13.             force *= w;
    14.             if (pinDistanceFalloff > 0f) force /= 1f + positionOffset.sqrMagnitude * pinDistanceFalloff;
    15.  
    16.             rigidbody.velocity += force;
    17.         }
    Best,
    Pärtel
     
  12. corjn

    corjn

    Joined:
    Feb 6, 2014
    Posts:
    37
    Hey @Partel-Lang,

    I have an issue figuring out how to reset the dead target map.

    [​IMG]

    Here, I made my character die on the default and included in puppetmaster getting up animation. The dead body will somehow "save" his latest alive position. I would like to reset that position on the dead body once the death blending is done (have a tpose for example, or an idle pose) You can see here he will keep that weird position (his torso on the image) once dead. It's important because in my game the dead body is interactible.
    How do you think I should proceed to do that ?

    Thanks in advance for the help and time,

    Jonathan

    Edit : Made some more tests and I guess my problem is coming from the fact puppetmaster is (brillantly) determining the configurable joints connected anchor when all the bones are not set up as muscles in puppetmaster.
    What I want is basically reset puppet connected anchors (configurable joint) to their default settings (before playing, in the editor. often the character will be in tpose) and I want to do that once the character is dead, so when the animator is automaticaly disabled by puppetmaster.
    So, is it possible to do it with puppetmaster (a bool in editor or by calling a function), or do I need to make my own script ?
     
    Last edited: Dec 19, 2017
  13. pigglet

    pigglet

    Joined:
    Aug 13, 2014
    Posts:
    31
    Hey! I have a workflow question. Is it a way to change a character model if I already setup the puppet master and have a lot of scripts and references over the whole hierarchy? Can I just add another model (with exactly the same skeleton) without runnnig the master once again and creating new puppetmaster, behaviours and all the setup from scratch?
     
  14. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    351
    I added your code but I'm still getting some strange results like were the player teleports back to where they crashed


    or when you crash sometimes it does a weird up down maneuver freakout
     
  15. Useless-Media

    Useless-Media

    Joined:
    Apr 19, 2015
    Posts:
    66
    Try this out
    Code (csharp):
    1.  
    2.  
    3. if ( b ) {
    4.       PuppetMaster.StateSettings s = new PuppetMaster.StateSettings ();
    5.       s.freezePermanently = true;
    6.       m_PuppetMaster.Freeze ( s );
    7.  
    8.       RootTransform.position = spawnPosition;
    9.  
    10.       m_PuppetMaster.state = PuppetMaster.State.Alive;
    11.       b = false;
    12. }
    13.  
     
    Last edited: Dec 21, 2017
  16. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,519
    Hi, guys, sorry for the delay, was hit by the annual Christmas support request tsunami.

    If you need to keep animating the player, don't set it to Dead state. Instead call behaviourPuppet.SetState(BehaviourPuppet.State.Unpinned) and set behaviourPuppet.canGetUp to false.

    Or use the PuppetMaster.OnDeath delegate to re-enable the Animator.

    Hey,
    Sorry, there's no way I can replace the references to parts of PuppetMaster, I simply can not have access to your scripts. But that is exactly the reason why BehaviourPuppet was designed no to include any direct references to any muscles or bones. You can just drag BehaviourPuppet and Fall from one character to another without breaking any references (unless they are set up in the Events).

    So basically, instead of adding public references to muscles to declaration space, use the methods in PuppetMasterMuscleAPI.cs: GetMuscle and GetMuscleIndex and stuff like that to find what you need in Start and cache them all for the sake of performance.

    Hey,
    Freezing a puppet permanently will destroy the entire PuppetMaster when the rigidbodies settle down so you can not set it's state back to Alive again. Use Dead state or Freeze without freezePermanently.

    Cheers,
    Pärtel
     
    pigglet and Useless-Media like this.
  17. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    880
    Should I use "Optimize Transform Hierarchy" before set up puppet master?
     
  18. EnriquePage91

    EnriquePage91

    Joined:
    Jul 2, 2015
    Posts:
    7
    Hello @Partel-Lang !

    First of all let me thank you profoundly for the work you've done - PuppetMaster and FinalIK look INCREDIBLE!

    I just started using them a few days ago and I'm blown away by the magnitude of its potential - I am sure this will accelerate deeply my development - and this is coming from someone who spent their whole BFA in animation trying to get procedural animation & particularly active ragdolls to work in Unity - unfortunately I attacked this without any plugins and ooohh my god was it a mess. It worked, but it was a mess.

    Now that I've bought these plugins, in less than 3 hours I had FinalIK working perfectly with UMA (I used UMA for my thesis too and this made everything ragdoll/procedural quite complicated for an Amateur like me lol).

    Unfortunately, I am trying really hard to implement PuppetMaster with UMA but I just can't get it to work. I downloaded the demo example you have on the " Integration " folder however it just won't compile properly.

    It keeps on throwing 2 errors pointing out to UMADynamicAvatar being missing - the usual type or namespace missing kind of thing.

    I can't seem to fix this and I can't find any relevant information on what might be causing it.
    I've tried moving UMA into the plugins folder since I figured it probably had to do with the fact that the BuildUMAPuppet.cs script is on the Plugins folder, however the error still appears. If I take the folder including BuildUMAPuppet.cs out of the plugins folder, the same error occurs.

    I have to say I did move a lot of folders around (particularly from assets I downloaded) as to not have them mixed up with my own scripts and stuff - however I don't have any other compile errors so I would assume the namespaces are not conflicting with each other nor anything like that. PuppetMaster works perfectly fine too, it's just the UMA integration which throws that error - this is what makes me wonder if perhaps it wasn't because of me moving folders around that this happened. However... I tried starting from scratch and just adding PuppetMaster and UMA 2.7 (from GitHub since it's the most stable and updated version) and I am still getting the same problem even without modifying the hierarchy.

    Like I said, I'm not an expert coder - I'm more on the design side - and even though I do code a lot, I learned most of it on my own so you can imagine just how tragically implemented my code tends to be - I am sure I am missing something trivial however I can't get the example to run and simply trying to replicate what you're doing in that script doesn't seem like the best idea until I figure what's happening here.

    I also tried adding "using UMA" to the BuildUMAPuppet.cs but it doesn't recognize the UMA namespace!

    What am I missing here? Any way I can help you figure it out by posting any images, or videos or something?

    Please let me know and once again thanks for everything. Amazing assets, I insist.


    2017-12-28 (12).png 2017-12-28 (13).png
     
    Last edited: Dec 28, 2017
  19. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,519
    Hey,
    You can't use "Optimize Transform Hierarchy", that would not allow us to make scripted changes to animation.

    Hey,
    Seems like they have updated UMA and broken the integration.
    I updated it, please download from
    Code (CSharp):
    1. https://www.dropbox.com/s/7485xlqza4z4e4d/UMA%202.6.2%20%28Unity%205.6.1.f1%29.unitypackage?dl=0
    .

    Built with Unity 5.6.1.f1 for UMA version 2.6.2.

    Cheers,
    Pärtel
     
    EnriquePage91 likes this.
  20. bumd

    bumd

    Joined:
    Aug 20, 2017
    Posts:
    4
    Hello,

    I think character puppet script in demo scenes is not working as intended in 2017.3, in melee demo scene, character doesn't rotate to camera forward. It was working in 2017.1
     
  21. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    3,998
    FWIW, UMA will be updating soon-ish to the 2.7 branch on GitHub.
     
  22. EnriquePage91

    EnriquePage91

    Joined:
    Jul 2, 2015
    Posts:
    7
    Thanks for the quick response and help! Will check this out and get back at you if there are any issues since I am using UMA 2.7 which I got from their GitHub.

    Thanks Again!

    UPDATE 1:

    Yes, still having issues.

    Apparently now there are more - it's throwing 4 problems when imported all of the same nature
    as the previous one.

    UPDATE 2:

    Hey, decided to re-import the asset you just sent me after deleting it to see if some weird stuff could have happened since I had those scripts open in visual studio as I imported them first.

    As a matter of fact this seems to have cleared the errors, I guess Visual Studio was bugging your scripts with the previous instances somehow.

    Will update if something bad happens but as of right now the issue seems to be gone.

    UPDATE 3:

    Checked the uploaded content out but unfortunately the example scene has two missing prefabs which I can't really figure out what they are and I'm having a hard time figuring out how exactly to handle the BuildUMAPuppet script. Any suggestions? I'll upload a look of the hierarchy for you to see which ones they are.

    Thank you again!

    2017-12-30.png
     

    Attached Files:

    Last edited: Dec 30, 2017
  23. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,519
    Hey,
    It's a known issue, please import this patch until I get the next version up.

    Thanks for the heads-up!

    Oh, sorry about that, please import again from here.
     
    EnriquePage91 likes this.
  24. EnriquePage91

    EnriquePage91

    Joined:
    Jul 2, 2015
    Posts:
    7

    Sorry Partel! I really want to stop bothering you, I am sorry about it but unfortunately there are still some issues.

    At this point I've got to guess it's really probably something better addressed as soon as UMA is updated but I'll still point you out to my discoveries in case you can somehow help me without wasting too much of your time.

    I downloaded the updated Demo you provided and now the missing assets are there - as I imagined one of these was the readme file you tend to have on your examples - the other one was the object with the BuildUMAPuppet script associated.

    I've had serious problems (both in my custom scene with my custom scripts that I have written based on your UMA with FinalIK tutorials which gives a good overview of your particular workflow) getting the BuildUMAPuppet script to recognize the avatars:

    - on the Example Scene provided, the BuildUMAPuppet script associated to the BuildUMAPuppet GameObject does detect the "avatars" that are generated by the UMA Crowd - however if I try to use this method with my generated avatar it just doesn't even recognize it. It won't let me drag and drop it into the field in the same way one would do so in your tutorial.

    - Unfortunately, even if in the example scene the avatars are detected by the BuildUMAPuppet script, the script itself does not seem to be working like intended to : When I run the example and utilize it in the way (I would imagine) you intended it to be used, the collision boxes get instantiated and there's even a duplication of the gameObject associated to the UMA, however the skinned mesh associated to the ragdoll is never generated. (See video 1)

    - I've come however to find an Editor fix for this - I noticed that by adding the BuildUMAPuppet Script to one of the generated characters (on the example scene) and then utilizing that character as if he himself WAS the BuildUMAPuppet GameObject (the one you want us to use to drag and drop the avatars into basically), somehow fixes
    this issue. After doing so, If I drag and drop ANOTHER UMA Avatar into this new Avatar's script (the avatar which is now being used as the BuildUMAPuppet GameObject) somehow fixes everything. (See video 2)

    Any suggestions?

    It is a bit confusing as I do not see why this would be relevant. Particularly since we clearly don't want to have that script associated to the actual Avatar that has been generated. My only guess is that by adding the BuildUMAPuppet Script to an actual Avatar the references of that one might be preserved somehow and used for the generation of the following Avatar's PuppetMaster? Seems weird, and particularly unintuitive since I am 99% sure you did not intend
    for this script to be associated to any Avatar's game object at any point - and by giving the code another quick look I don't see how this would be happening anyway - but I have no better guesses as to what's happening.

    VIDEOS:

    (1)


    (2)



    Sorry for the continuous annoyance, hopefully you'll have some info to point me out in the right direction without taking too much of your time, otherwise I fully understand and will simply wait for the update.

    Thanks again!



    UPDATE 1:

    So to start with, UMA 2.7 approaches generation in a much more streamlined and user friendly way than it used to - in order to do this you have to use the new script DynamicCharacterAvatar instead of the UMADynamicAvatar.

    I hadn't realized this difference but know it's safe to assume that was the reason behind not being able to process my specific character with the script provided in the examples (which is using the DynamicCharacterAvatar instead of the UMADynamicAvatar script required in BuildUMAPuppet). I have tried to get a reference to the UMADynamicAvatar instance generated, however I haven't had any luck with that just yet, will have to do some more digging.

    I am not sure if perhaps UMA has replaced UMADynamicAvatar with DynamicCharacterAvatar but I wouldn't think that is the case, my best guess is DynamicCharacterAvatar is simply a script meant to be user-friendly so I should be able to somehow get access to the instance of
    UMADynamicAvatar dynamically.

    I've been looking at the PuppetMasterUMATools and what it looks for on the function used
    in the BuildUMAPuppet script. Knowing that it seems the only thing PuppetMasterUMATools requires out of the UMADynamicAvatar instance is the Animator associated to it I will try to solve this issue myself - will update if I have any success on the process - however quick tweaks have not gotten me anywhere as of now.

    Happy new year to everybody!
     
    Last edited: Jan 2, 2018
  25. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    351
    Any ideas on this?

     
  26. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,519
    Hey,
    If you already have some sort of a fix, I'd rather wait for them to release that 2.7 before making another update to the integration package, especially if they have changed UMADynamicAvatar to DynamicCharacterAvatar..

    Hey, sorry, I must have missed that post.
    What is the state of the PuppetMaster when it teleports back to the crash point? I mean is it still Alive, Dead or Frozen?

    It is very difficult to debug this based on just videos, so if there's any chance you could send me that project or a repro, it would probably be the quickest solution.

    Cheers and Happy New Year!
    Pärtel
     
  27. Alfonso_CJ

    Alfonso_CJ

    Joined:
    Nov 19, 2015
    Posts:
    35
    Heya! Happy new year!
    How do I avoid this? And joints spazzing out in general?
    [​IMG]
     

    Attached Files:

  28. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,519
    Hey,
    It's a general problem with ragdolls in PhysX, would happen with regular ragdolls just the same. Small colliders like the ones on the hands easily get stuck and penetrate scene colliders.

    You could increase the "Solver Iteration Count" in PuppetMaster.
    Try enabling joint projection:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using RootMotion.Dynamics;
    4.  
    5. public class EnableJointProjection : MonoBehaviour {
    6.  
    7.     public PuppetMaster puppetMaster;
    8.  
    9.     void Start() {
    10.         foreach (Muscle m in puppetMaster.muscles) {
    11.             m.joint.projectionMode = JointProjectionMode.PositionAndRotation;
    12.             m.joint.projectionDistance = 0.01f;
    13.             m.joint.projectionAngle = 30f;
    14.         }
    15.     }
    16. }
    Also, check out all the variables under Edit/Project Settings/Physics. Adjusting "Default Contact Offset" and other parameters (depending on your Unity version, some new ones in Unity 2017 versions) might help.

    Best,
    Pärtel
     
    Useless-Media likes this.