Search Unity

  1. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  2. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Participate with students all over the world and build projects to teach people. Join now!
    Dismiss Notice
  5. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  7. 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. JRRReynolds

    JRRReynolds

    Joined:
    Oct 29, 2014
    Posts:
    155
    @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:
    537
    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,752
    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:
    537
    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:
    373
    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. flow-

    flow-

    Joined:
    Apr 19, 2015
    Posts:
    108
    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:
    16
    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,752
    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:
    373
    I'm using puppetMaster.behaviours[0].Activate(); To activate the falling behaviour
     
  10. flow-

    flow-

    Joined:
    Apr 19, 2015
    Posts:
    108
    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,752
    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:
    55
    Hey @Partel-Lang,

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



    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:
    41
    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:
    373
    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. flow-

    flow-

    Joined:
    Apr 19, 2015
    Posts:
    108
    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,752
    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 flow- like this.
  17. ksam2

    ksam2

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

    EnriquePage91

    Joined:
    Jul 2, 2015
    Posts:
    29
    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,752
    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:
    6
    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:
    4,452
    FWIW, UMA will be updating soon-ish to the 2.7 branch on GitHub.
     
  22. EnriquePage91

    EnriquePage91

    Joined:
    Jul 2, 2015
    Posts:
    29
    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,752
    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:
    29

    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:
    373
    Any ideas on this?

     
  26. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,752
    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?
     

    Attached Files:

  28. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,752
    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
     
    flow- likes this.
  29. flow-

    flow-

    Joined:
    Apr 19, 2015
    Posts:
    108
    Can the Ragdoll detect collisions, i want loop all ragdoll collider and check if the ragdoll collder hit a other object and i don't really want create a new script and assign it to all ragdoll colliders with OnCollisionEnter, so my question is if puppetmaster take count of other colliders and have somthing like a public collider[] HittingColliders

    EDIT: I made now a own script and its working perfect but is there a tracking function?
     
    Last edited: Jan 25, 2018
  30. cspid

    cspid

    Joined:
    Apr 25, 2014
    Posts:
    13
    Hi Partel, I've just bought Puppet Master and Final IK and they're really remarkable tools! I saw it mentioned that you were working on a catch-fall behaviour that could transition out of the stumbling behaviour, is that still in the works? Can you provide some advice on how best to have a puppet recover from stumbles in a realistic way?

    Thanks so much
     
  31. Sovogal

    Sovogal

    Joined:
    Oct 15, 2016
    Posts:
    87
    Partel,

    For the most part, your BehaviourPuppet settings in the Puppet Raycast hit example scene is exactly what I need. However, for gameplay reasons, I need to glue my puppet's feet to the ground. Is there a way I can do this using existing settings, or would there be some necessary new script component I would have to write?

    Thank you for your time.
     
  32. h00man

    h00man

    Joined:
    Apr 17, 2017
    Posts:
    29
    hey partel,
    i'm using your puppet character controller and i have added a new animation(wall climb)
    to Humanoid Third Person Puppet animation controller.
    the problem is that your animation controller script doesn't let my character to move up and climb up the wall.the animation of wall cimlbing will be played whith no broblem but my player dosent move up the wall.
    how do i change the script to tell my character to move up?
    thanks
     
  33. flow-

    flow-

    Joined:
    Apr 19, 2015
    Posts:
    108
    When the animation supports Root Motion then check the "Apply Root Motion" in the animator, if not you need to write your own script to make it work, this is not a Puppet Mater related question, post it in the correct thread
     
  34. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,752
    Hey,
    If you are using BehaviourPuppet, that will add MuscleCollisionBroadcasters to the ragdoll rigidbodies that already listen to the collision events. You can use BehaviourPuppet.OnCollisionImpulse delegate to get a call whenever the ragdoll collides with anything:
    Code (CSharp):
    1.     public BehaviourPuppet puppet;
    2.  
    3.     void Start() {
    4.         puppet.OnCollisionImpulse += OnCollisionImpulse;
    5.     }
    6.  
    7.     void OnCollisionImpulse(MuscleCollision m, float impulse) {
    8.         Debug.Log("Puppet collided with " + m.collision.collider.name);
    9.     }
    Impulse is the damage it has done to the puppet, the amount of unpinning it has resulted with.

    Hey, thanks for the purchases!

    I tried developing that, but haven't arrive to a solution that could be trusted to deliever satisfactory results in a stable way.
    For now, the best way would be to use the "On Lose Balance" event of BehaviourBipedStagger to call a script that crossfades the animator to a catch fall pose based on the direction of the velocity of the puppet's body.

    Hey,
    You could just create kinematic rigidbodies to where the feet should be an add Joints to attach those rididbodies to the feet muscles.

    Hey,
    It is just a demo controller that was designed to demostrate what PuppetMaster and Final IK do. I suggest you replace it with Opsive or other similar thing that has all that functionality already built in and supported.

    Maybe if you set Ground Sticky Effect to 0 it will work.

    Cheers,
    Pärtel
     
  35. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    385
    Partel,

    I receive a null reference exception if I try to register to the OnDeath event/delegate in PuppetMasterStates during OnEnable(). It works fine if I register to it in Start().

    Code (CSharp):
    1.  protected override void OnEnable()
    2.     {
    3.         base.OnEnable();
    4.         behaviorPuppet.puppetMaster.OnDeath += OnDeath;     //Event from PuppetMaster
    5.     }
    The OnCollisionImpulse event works if I register to it in OnEnable so I'm not sure why the design pattern would be different for different events.

    Since I pool my enemy puppets, I am in the habit of placing all event registrations and unregistrations in OnEnable and OnDisable. I assumed that was the correct way to handle pooled objects.

    Is there some reason why OnDeath will not work in OnEnable()?

    Thanks
    Allan
     
  36. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,752
    Yes, behaviourPuppet.puppetMaster is unassigned before Start. That is because of the design that allows for behaviours to be moved from one puppet to another without having to change any references to puppetmaster or bones or whatever.

    Use a direct reference to the PuppetMaster component to add that OnDeath listener.

    Best,
    Pärtel
     
  37. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    385
    Partel,

    Thanks. That makes sense.

    Allan
     
  38. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    385
    Useless,

    I noticed your question about ragdoll collisions and I know Partel has already responded but I thought I would give you some feedback as well.

    I use ragdoll collisions exclusively for all of my character combat. So if you search in this forum thread for OnCollisionImpulse, you'll see a lot of discussion on the topic with numerous posts from me. Here is a link to the thread page where I give information to another user regarding OnCollisionImpulse and how to use it. I also use the impulse value that is returned through that event in order to decide how much damage my characters take.
    https://forum.unity.com/threads/pup...ics-tool-released.358445/page-19#post-3142184

    You can also lookup all of the posts I've made in the Puppet Master forum. I also use Collision Resistance Multipliers in Behavior Puppet in order to decide what objects my ragdolls will collide with based upon physics layers and how much each of those collisions will "resist" the lose balance effect. Some time ago, Partel updated Puppet Master to allow the use of multiple Collision Resistance Multipliers based upon my request. As an example: This allows you to have a player ragdoll that can respond to Ice, Large Debris, Small Debris, Enemy Ragdolls, Enemy Props etc. and respond differently based upon the physics layers and collision resistance multiplier values.

    Hope that helps.

    Allan
     
    Partel-Lang likes this.
  39. flow-

    flow-

    Joined:
    Apr 19, 2015
    Posts:
    108
    Thank you, i will take a look
     
  40. cspid

    cspid

    Joined:
    Apr 25, 2014
    Posts:
    13
    Hi Partel,

    I'm having trouble recreating the behavior of the Third Person Puppet (Puppet & Stagger) from the Stagger demo with a character i built from scratch. I've copied over all the settings and the puppet works fine except that it doesn't stagger - it simply falls as if it were using the fall behavior.

    Any advice would be appreciated.

    Thanks
     
  41. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,752
    Hey,
    It might be the mass of the ragdoll rigidbodies. In the stagger example they are all set to 1, but the BipedRagdollCreator uses a biometric mass distribution if you used it to create your ragdoll. Try settings all rigidbody masses to 1.

    Best,
    Pärtel
     
  42. RakNet

    RakNet

    Joined:
    Oct 9, 2013
    Posts:
    86
    I'm using the InteractionSystem to pick up Props while using PuppetMaster. However, if the Prop is picked up the character's arm goes crazy for about a second while if the Prop is not picked up the end of the pickup animation ends normally.

    Code:
    InteractionObject.Message interactionObjectMessage = new InteractionObject.Message();
    interactionObjectMessage.function = "IOE_Interaction";

    In IOE_Interaction:
    propRoot.currentProp = puppetPropController

    In PropRoot.cs:
    If I put a return at the top of AttachProp(Prop prop) the pickup animation ends normally (as I said)
    The line line that breaks things is:
    puppetMaster.AddMuscle(prop.muscle, prop.transform, connectTo, transform, prop.muscleProps, false, prop.forceLayers);

    I think the interaction system doesn't take into account adding new muscles, or PuppetMaster doesn't like the interaction system running while a muscle is added?

    Maybe the axe touches the ground while being picked up and causes physics to go flying? But I turned off all colliders on the axe and the issue still happens.

    The funny thing is if I have a breakpoint in IOE_Interaction it works fine. It's only if I run without breakpoints the arm goes crazy.

    Video:
    www.poleaxe-games.com/PuppetMaster/InteractionObject.mp4

    This is using the latest versions of PuppetMaster and FinalIK
    PuppetMaster .7
    FinalIK 1.7
     
    Last edited: Jan 31, 2018
  43. RakNet

    RakNet

    Joined:
    Oct 9, 2013
    Posts:
    86
    This is a bugfix I put at the end of RemoveMuscleRecursive in PuppetMasterHierarchyAPI.cs

    // Bugfix - Reenable collisions since this joint is no longer connected.
    // This fixes a bug where a weapon is dropped, picked up by someone else, then cannot hit the original wielder
    Collider[] colliders = joint.transform.GetComponentsInChildren<Collider>();
    for (int i = 0; i < muscles.Length; i++)
    {
    Collider[] otherColliders = muscles.colliders;
    foreach (Collider c1 in colliders)
    {
    foreach (Collider c2 in otherColliders)
    {
    Physics.IgnoreCollision(c1, c2, false);
    }
    }
    }
     
  44. bumd

    bumd

    Joined:
    Aug 20, 2017
    Posts:
    6
    I'm having a weird issue with puppet master.

    First I opened up melee scene saved as new and created some classes for two days. I did not change any puppet master value or modify it any way i know of. Only thing I did was

    • replaced pilot model with maximo one,
    • changed time scale to 0.01,
    • changed skinned mesh layer from default to something new layer which has no collider and no bones too. It's just one skinned mesh.
    After that also scene was working fine for 2 days. Also this happened to me with previous version and unity 2017.1b too.

    • I can't pick up props, randomly it stops working, I have to drag n drop a new prop prefab to scene every time. And it fixes the picking up problem.
    • Player puppet could not collide and fall of if the collider is bot puppet. Neither of them is losing any balance.
    • If i drag and drop a new bot puppet and disable it's AIcontroller script, so it supposed to be fresh bot, it goes to fly and it's physics behaves unnatural. Like making a half circle in air and flying far.Second pilot next to first pilot is a new prefab.
    If I load up original melee scene, bot puppet are flying but props are ok. Yet if I modify props colliders position or sometime not even changing anything, prop picking up bug becomes alive.

    Also tried to reimport the package over, but it did not solve the issue. Only way to fix it to create a new project and import puppetmaster. PS Nevermind that did't work either. I do believe this two issues are connected somehow. Something bugs/glithes unity physics, joints, component, memory leak or something, then this two issues appear. Only guessing here because have no idea what is happening.

    Here is a video:

     
    Last edited: Feb 3, 2018
  45. bumd

    bumd

    Joined:
    Aug 20, 2017
    Posts:
    6
    Ok, update...
    1. installed unity 2018 beta, new project > imported puppetmaster > no physics weirdness > closed
    2. opened my buggy project with 2018 beta > weirdness happens > closed
    3. opened 2018 again new project > imported puppetmaster > weirdness is back so now it seems i can't get rid of it.
    I have no idea how to solve it, yet it doesn't give any errors, no crashes and my other projects are working fine.I have latest gfx driver, rx 480 / win10 64 also same result happens on mac and also windows builds.

    Also tried to increase physics solvers and puppet iterations to 100 to see if it changes anything

    here's another video, re-installed unity 2018, new project > imported

    Another Update: I made it interpolate for user and bot puppet as demo scene readme (and animate physics to normal) and this fixed the flying issue, after collision physics looks normal. But default scene and no interpolation for both character controller and puppet rigidbodies, the issue persist.

     
    Last edited: Feb 3, 2018
  46. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    573
    Hey there. I am using Opsive TPC with Puppetmaster. I followed the video as well as what was on Opsives site under integration as well as looked at Justins demo scene. Everything looks to be right with my character. The only difference is my character is spawned at the beginning. When I do spawn, my puppet ends up just laying on the ground where I originally was, you can then see where I did spawn in the background. Any ideas? All settings are default, I am using the Puppetmaster ragdoll, I have TPC's puppet bridge attached to the puppet object, I have the behaviors, my layers for puppet and player are separate, etc. I am using Grounder IK, FBBIK, and AimIK but I tested it with them off and nothing changed.

    --- One thing I do notice is all my settings and setup are the same as the pilot in the TPC demo scene except the pilot has a white skeleton inside of the character. I do not see one, what am I missing that is not giving me that? I have all the game objects and I did all the setup. I have the child objects within behavior. I have the all necessary scripts I need added but I also just now noticed that atruntimee the pilot character's puppet receives a bunch of musclebroatcast and joint scripts, which my character does not. I am not sure where they are coming from? My layers are looking fine as well.


    *** - Edit
    So, I did get it working for a few minutes after starting with a fresh TPC character, then I finished setting up TPC and FIK, now it doesn't work anymore, the puppet just falls down on the ground in front of me again.. ugh..

    Here is a clip of it in action. The puppet just falls off as soon as I start the game. All of the pin and weight settings are all default. It was fine for a little while, then all of a sudden, now it is not.

    I thought at first it was because I was spawning my character, then I also thought it might have been because of FIK, but I stopped both and no difference. When it was working the scripts for muscle broadcast were showing up on the puppetmaster object, now they are not anymore and it is no longer working. There has to be some correlation?

    More Edit ---- Ok, we are getting close here. The video directly below is of how I have been able to get it working so far, but have no idea what is now going on with that. I copied the Puppetmaster / FIK - AimIK and used IK before physics, but this is what is happening. I am not sure what is up with my legs and waist either. I tried adjusting things for the head, but all it ended up doing was either making the neck not move at all when I moved the mouse, or it would make it do what you see below.

    I adjusted the mapping weight, it put the legs back to normal, but then I had no more puppet basically.

    --- Ok, looks like it was a check box for mapping that fixed the legs.
     
    Last edited: Feb 5, 2018
  47. internethip

    internethip

    Joined:
    Oct 21, 2013
    Posts:
    20
    Is there a way to instantly move both the Character Controller and the Ragdoll without causing stuttering while the puppet is alive?

    I've been trying some stuff but it seems like the physics updates always adds a few frames of lag before moving the ragdoll and the mesh to the correct position.

    To avoid floating-point precision errors I want to reset the whole world in "runtime".

    So basicly what I want to do is:
    Code (CSharp):
    1. transform.position = newPosition;
    On the CharacterController about 100 Vector points without the ragdoll lagging behind in the move.
     
    Last edited: Feb 4, 2018
    wisniowy88 likes this.
  48. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    573
    What if you just temporarily disabled it, then reenabled it once you reached the destination?


    -----

    I noticed that my character started to slowly over time start to jitter up and down. I went to go make some coffee and a sandwich, I came back to this. I tried adjusting a bunch of things but aside from the main mapping I could not find something to fix this. I saw it was said to try and flatten your muscle hierarchy, this was with that already done. My npcs don't seem to have the issue strangely.


    Also, is there supposed to be a little tiny capsule collider attached to my player between his feet?



     
    Last edited: Feb 5, 2018
  49. internethip

    internethip

    Joined:
    Oct 21, 2013
    Posts:
    20
    Turns out doing it in fixed update made the issue better for me. I calculate the distance I want to move everything in fixed update and then move everything at once. This is was my recenter function on the CharacterController:

    Code (CSharp):
    1.     public void Recenter(Vector3 position)
    2.     {
    3.         transform.position = position;
    4.     }
    5.  
    However, I had issues with the ragdoll colliding with things during this move (Only intermittently but enough that it would create a gameplay issue)

    After Partel's answer below I changed my function to this:
    Code (CSharp):
    1.     public void Recenter(Vector3 position)
    2.     {
    3.         puppetMaster.Teleport(position, transform.rotation, false);
    4.     }
    5.  
    Now it works flawlessly, just had to take into account that the move using Teleport() doesnt happen instantly and rewrite some of my code around that. No biggie for a flawless origin reset tho!
     
    Last edited: Feb 6, 2018
  50. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,752
    Hey,
    Did that bugfix fix the issue you had earlier with the Interaction System or was it for another bug?

    Hey,
    I'm suspecting it has something to do with the Project Settings. Layer Collision Matrix and maybe some physics settings. Try copying the "ProjectSettings" folder from a working project to the buggy one. If that's not it, could you send me that buggy project so I could take a closer look at what's going on?

    Ragdoll falling off usually happens when PuppetMaster initiates and finds the muscle positions not matching their targets. It should log a warning for you in that case. Usually happens when people move the target root (the one with the Animator and character controller stuff) to the spawn position right after spawning the puppet, leaving the ragdoll hierarchy behind. In that case move the root Transform of the entire character instead of just the target root.

    Hey,
    In the latest PuppetMaster, it is done by calling puppetMaster.Teleport(...);

    Hey,
    Did you have "Fix Target Transforms" enabled in PuppetMaster when it happened?
    I have no idea what that tiny capsule is, can you find the gameobject that it is attached to?

    Cheers,
    Pärtel