Search Unity

PuppetMaster - Advanced Character Physics Tool [RELEASED]

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

  1. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hey,
    Please grab this package.

    Check out the ParticleCollisionHandler script on the Particle System in the "Puppet Particle Collsion" scene. It uses OnParticleCollision to send particle collision events over to MuscleCollisionBroadcaster as raycast hits.

    Best,
    Pärtel
     
    rastleks likes this.
  2. rastleks

    rastleks

    Joined:
    Jul 17, 2014
    Posts:
    49
    Thank you very much, it's working now!

    Now I have another issue. I use Puppet Behavior, but without falling behaviour. It was working. But recently I noticed that sometimes my puppet getting up without any animation, just like it was just "unmapped" and then mapped again. It look's very unnatural.

    What could I have done wrong?
     
  3. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hey,
    Maybe you have some animation code running while the puppet is getting up and that sometimes crossfades out of the getting up animation?
    Make sure you don't call for any crossfades while behaviourPuppet.State != BehaviourPuppet.State.Puppet;

    Best,
    Pärtel
     
  4. rastleks

    rastleks

    Joined:
    Jul 17, 2014
    Posts:
    49
    Hi. May be it's stupid question, but I think I miss something.

    I have 2 characters root. Characters are the same, puppet behavior is the same, puppet master component settings is the same.

    The only difference is the position in the hierarchy. The first is fully unparented (character root is under scene root), the second is parented to something like "GameLevel/Part1/LevelObjects/Platform".

    The first character puppet works OK (falls when some collider touch him with the force). The second never falls. Unparenting / parenting this roots in Runtime DOES make the difference.

    Why it works this way?
     
  5. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hey,
    It's an optimization preventing the processing of internal collisions, MuscleCollisionBroadcaster.cs ignores collisions with objects that have the same transform.root. BUT I updated PuppetMaster last week, that limitation is removed now, so please update the package to v1.1.

    Cheers,
    Pärtel
     
  6. illia_rybas

    illia_rybas

    Joined:
    Feb 2, 2018
    Posts:
    5
    Hey! Probably there is already an answer to my question.
    I have a humanoid character. And I wand to mix ragdoll logic for upper body and animator for legs. I want to achieve this logic - when my character runs forward, the running animation is played for his legs, and the upper body is deflected backward in physics, just like a ragdoll works.
    Is it possible with puppet master asset?
     
  7. rastleks

    rastleks

    Joined:
    Jul 17, 2014
    Posts:
    49
    Hi. I use puppet master and Ease Character Movement 2 simultaneously.

    Character Movement 2 have rigidbody. Puppet Master have a lot of rigidbodies. As far as I know having nested rigidbodies is bad. Is it really bad?

    What will be right way to use puppet master parented to character controller with rigidbody?

    Only workaround I have in my mind is to unparent puppet master root and move it using Unity constraints, but it doesn't seems right.
     
  8. rastleks

    rastleks

    Joined:
    Jul 17, 2014
    Posts:
    49
    Yes it is. You can assign different pinning weight for your upper body so legs will be fully controlled by the animation and upper body will be more affected by physics.
     
  9. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hey,
    Yeah, just expand the Muscles array on the bottom of PuppetMaster and reduce pin weight for all the upper body muscles. Can also use PuppetMaster.SetMuscleWeightRecursive(...) to spare your mouse.

    Hey,
    No, don't parent PM to the character controller rigidbody. PM should be a sibling to it. So the hierarchy looks like this:

    - Root - empty gameobject, just a container for the rig
    - Character controller (All the Character Movement 2 scripts and Animator)
    - PuppetMaster

    Make sure PuppetMaster's "Target Root" points to the character controller object.

    Best,
    Pärtel
     
  10. rastleks

    rastleks

    Joined:
    Jul 17, 2014
    Posts:
    49
    Thank you, now it seems to work, but there is other problem I have :)

    I have something like QTE finishers in my game. When this QTE starts I wanna be sure that puppet will ignore any collision.

    What I do now:
    1. Check if puppet behaviour is in Puppet stay.
    2. Boost immunity on all muscles.
    3. Boost immunity on all muscles on every frame during QTE.

    What I expect:
    Until QTE ends there is NO CHANCE that my character will loose balance.

    What I have:
    Character loosing balance in QTE :|

    What is my mistake can be?
     
  11. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hey,
    Puppets fall only on 1 condition and that is when a muscle drifts farther than knock out distance from its target. Set behaviourPuppet.knockOutDistance to Mathf.Infinity when your QTE starts.

    Best,
    Pärtel
     
  12. sfilo

    sfilo

    Joined:
    Oct 23, 2012
    Posts:
    30
    Hi Partel,
    First of all thanks for making PuppetMaster, it's great!

    I am using setting BehaviourPuppet with NormalMode Active because I need puppets to collide with one another. But this makes the finger end of the feet point up instead of being on the ground as with using Unmapped.
    What am I doing wrong, should I not use Active mode to make puppets collide with one another or is there something wrong with the ragdoll setup?
     

    Attached Files:

    The11thAlchemist likes this.
  13. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hey,
    Take a look at the foot collider, it is probably not aligned with the ground. Can't rotate colliders in Unity, so add a new child gameobject to the foot rigidbody and copy-paste the collider onto that. Then you can rotate that child object to fix the problem.

    Best,
    Pärtel
     
    Ghosthowl likes this.
  14. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,490
    Hi,

    Can I ask for some help / advice, how can I make the player fall/interact with other NPC (same model etc as player from demo scene, just controller script disabled)? NPC and player interact with everything except each other... I have checked the project layers/physics setting but nothing seems to help currently.

    Demo vid:
     
  15. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hey,
    1. Make sure the layers of the ragdolls are not set to ignore each other in the Layer Collision Matrix.
    2. Make sure the puppets have the other puppet's ragdoll layer included in BehaviourPuppet's "Collision Layers"

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

    khos

    Joined:
    May 10, 2016
    Posts:
    1,490
    Awesome thanks Pärtel, I added another layer for the "npc's", now things work perfect!
     
  17. lawsonh

    lawsonh

    Joined:
    Jul 25, 2018
    Posts:
    80
    @Partel-Lang Hey Partel, thanks for the wonderful asset.

    But I have a problem when trying to use it with 2 puppets.

    Both puppets have Capsule collider and Rigidbody with rotation constraints frozen.
    I dragged BehaviourPuppet prefab to one of the puppets and tweaked it to be easily knocked out and I removed all animation events also.

    When that puppet gets knocked out, the other puppet starts behaving strangely. it will start rotating downwards to be almost laying on the ground even though the capsule collider had rotation frozen. Any idea what is going on?

    Also, both puppets were twitching every 1 second, but I solved that by unchecking "can get up"
     
  18. lawsonh

    lawsonh

    Joined:
    Jul 25, 2018
    Posts:
    80
    Sorry for bothering, it was a bug on my end, fixed now
     
    Partel-Lang likes this.
  19. jjejj87

    jjejj87

    Joined:
    Feb 2, 2013
    Posts:
    1,117
    Hello Partel, first of all great product! Love Puppetmaster!

    But I do have an issue that looks like needs your help.

    Basically, I use Puppetmaster for humanoid monster and spawn them when they are nearby the player.
    And I get this issue where the editor/standalone build will freeze for no real reason.

    This happens when I am spawning about 10 in a row (I take 2 sec break between spawns)
    and this happens about 5% of the time. So, not all the time.

    This is my profiler screenshot. Any idea what could be causing this? I didn't do much to the base system, so it is more like spawning sample characters in series. Hope you can guide me towards a fix. Thanks. puppetmaster.jpg
     
  20. renat_k

    renat_k

    Joined:
    Mar 22, 2016
    Posts:
    8
  21. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hey,
    Puppets take time to initialize. Just instantiating objects takes a lot of time in Unity, even without PuppetMaster. You should use pooling and draw the puppets from the pool to spawn them. Please take a look at the "Puppet Respawning" demo.

    Hey, just replied to your email.

    Cheers,
    Pärtel
     
  22. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,490
    Just having some fun with some NPC's, hope they can swim:
     
  23. andylewisart

    andylewisart

    Joined:
    Nov 4, 2013
    Posts:
    19
    Hello,
    Has anyone had issues setting up Puppetmaster in 2021.2? I'm on 2021.2.4f1.

    I took the exact same model and brought it into both 2020.3 and 2021.2. Works fine in 2020.3. In 2021.2 this happens on play:

    upload_2021-12-22_14-42-57.png



    My existing assets ported from 2020.3 that have Puppetmaster still work, strangely enough. But I can't seem to create new assets with Puppetmaster without coming across the above issue. Using Puppetmaster 1.1.
     
  24. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hey,
    Does enabling "Support Translation Animation" in PuppetMaster fix that?

    Haha, nice :D. Should add some buoyancy physics for ragdolled puppets.

    Cheers,
    Pärtel
     
    andylewisart likes this.
  25. cybie

    cybie

    Joined:
    Sep 17, 2010
    Posts:
    91
    I have question about the how PuppetMaster works. I see there is a configurable joint on the pelvis, but all the joint motion are free. How is it keep to stay with the CharacterPuppet's rigidbody?

    Thanks
    David
     
  26. LeaBroudo

    LeaBroudo

    Joined:
    Mar 1, 2019
    Posts:
    2
    Hi Partel,

    I love your product but I have a bug I need some help on. I was using Unity 2021.1.7 and all the puppet animations worked fine, but I upgraded to 2021.1.9 and since then the character puppet's legs move like snakes. I've included a video: https://imgur.com/a/lREey4l

    The problem is that the puppet's feet under the Dummy PuppetMaster gameobject have their colliders turned off. If I turn both box colliders back on, the puppet goes back to normal. However, every time I unbalance the puppet and then rebalance it, the colliders disable and the snake feet come back. Is there any chance you could help me figure out how to fix this?
     
  27. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hey,
    PM uses pinning forces, that are basically world space AddForce commands to fix the puppet to its animation. If you set pin weight to 0, it'll continue animating using muscles only, but it will fall down as it's no longer forced to animation.

    Hey,
    I looked at the demos in that Unity version, but couldn't reproduce the problem. Can you see it happening in any of PM demos like Melee? Or can you send me some kind of a repro where I could test it? Btw, this is what disables the foot colliders while running around (to prevent them from getting stuck behind ground colliders).
    DisableFootColliders.PNG

    Best,
    Pärtel
     
  28. LeaBroudo

    LeaBroudo

    Joined:
    Mar 1, 2019
    Posts:
    2
    Hi Partel,

    I was actually able to figure out what went wrong, but I'd like to ask a different question I've been struggling with.

    I'm basically creating a VR chess game where each of the pieces are puppets. Each of the puppets has the same scripts as the AI puppets in the Melee scene. However, sometimes I want to be able to pick up one of the puppets with my hand. I do something similar to the Hanging scene, where I attach my VR finger's connected body to one of the puppet's configurable joints, and then set the puppet's pin weight to 0. This works well when I pick them up, but when I release them, they snap back to where the character controller initially was. I want the character controller to follow the puppet in these cases so that when I release the puppet it naturally just falls from its current position and onto the floor.

    I currently modified UserControlAI so that when I am grabbing a puppet, I do the following:
    Code (CSharp):
    1. state.move = Vector3.zero;
    2. characterControllerRigidbody.MovePosition(puppetFootTransform.position);      
    This works some of the time, but I think this conflicts with what the CharacterPuppet script is trying to do, and I think because the puppet is airborne the character controller just keeps moving downwards like it's falling. Also, when I instead just do
    Code (CSharp):
    1. state.move = puppetFootTransform.position.normalized * moveSpeed
    the character Controller moves in the x, z plane, but not up in the y plane.

    Do you think there's a better way to move the character controller with the puppet when the puppet's pin weight is 0 and I am holding it in the air?
     
    Last edited: Jan 3, 2022
  29. WonkyDonky

    WonkyDonky

    Joined:
    Aug 24, 2014
    Posts:
    65
    Is DOTS version of PM (& Final IK) still under research? Are the current versions of PM & final IK compatible with DOTS projects?

    (+ Have you thought about using some of the new API? or Scriptable Objects?)
     
    Last edited: Jan 9, 2022
  30. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hey,
    If the puppets are just chess pieces, why do you need that complex character controller on them? Could have just normal puppets with BehaviourPuppet, call behaviourPuppet.SetState(BehaviourPuppet.State.Unpinned) when you pick them up and disable behaviourPuppet.canGetUp until you release them.

    DOTS joints still don't have drives and motors, which are essential to something like PuppetMaster so no, can't do it.
    About DOTS Final IK, that would require DOTS animation, but Unity DOTS animation tools are still in very tiny baby shoes. I mean if you look at the disclaimer: "This version is highly experimental" and "Not (yet!) for production use". I can't build anything, not to mention a production-ready tool on top of that.

    Best,
    Pärtel
     
  31. Felinde

    Felinde

    Joined:
    Sep 19, 2021
    Posts:
    18
    Hi! In the "Melee Grab" demo there's the possibility of grabbing the Teddy bear ... but only he. Is it possible to grab all the rigidbody of a scene?
     
  32. WonkyDonky

    WonkyDonky

    Joined:
    Aug 24, 2014
    Posts:
    65
    Is "Animate Physics" animator update mode necessary for a character? Should a custom animation system update with physics?

    If character has Full Body IK + Puppetmaster, would "Fix Transforms" checked in both be waste and unnecessary?
     
  33. Marseol

    Marseol

    Joined:
    Jan 16, 2022
    Posts:
    10
    Hello! Is there a way to keep the Character controller always in the same position as the Puppet even when it is hanging or in flight? Every second the Character Controller tends to fall. Cattura_02.PNG
     
  34. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    306
    Hello, I am having an issue I cannot figure out.

    How do you prevent the puppet to over stretch and have the limbs being pulled apart?
    The default implementation allows the limbs to be pulled apart and making the ragdoll go crazy.


    I would like to avoid this.

    Thanks for helping
     
  35. WonkyDonky

    WonkyDonky

    Joined:
    Aug 24, 2014
    Posts:
    65
    That's PhysX joint instability issue, if you change solver type to Temporal Gauss Seidel in Physics Settings it should at least prevent total explosion

    Other tips: https://docs.unity3d.com/Manual/RagdollStability.html

    the main issue is that you are forcing that position (in real life the arms would come off)

    @Hazneliel
    Example Solution:
    You could change the Target yellow sphere's configurable joint parameters "X,Y and Z Motion" to "Free" from "Locked" and then set "X,Y,Z Drive" parameters: "Position Spring" values and "Maximum force" values to something that works:

    Edit: Use Position Spring 15 000 or even higher

    (@Partel-Lang wouldn't those parameters be better for the demo so it doesn't glitch out so easily?)
     
    Last edited: Jan 21, 2022
    Hazneliel likes this.
  36. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hi all, sorry for the absence here, I was down with the flu

    Hey,
    in Grab.cs OnCollisionEnter(), there are a bunch of conditions for what to grab and what to not grab. It's all commented there, so you can get rid of some of those conditions like layer check and the otherPuppet stuff.

    Hey,
    No, if you have a custom animation system, then don't use Animate Physics. just update your custom animation in LateUpdate of some script. Fix Transforms is only needed if you have some bones used by PuppetMaster or IK that's position and rotation is not overwritten every frame by the (custom) animation. It is there to avoid PM-IK solving on top of their own results frame by frame, eventually causing error accumulation, some bones starting to spin and other unwanted stuff like that

    Hey,
    Do you have that dark gray object's layer added to BehaviourPuppet's "Ground Layers"?

    Thanks for that!
    I would default to that, but my earliest supported Unity version doesn't have Temporal Gauss-Seidel.

    Cheers,
    Pärtel
     
    WonkyDonky likes this.
  37. Marseol

    Marseol

    Joined:
    Jan 16, 2022
    Posts:
    10
    Hi! It's deliberately a non-ground. The Puppet is raised by the gray object just to simulate my character when he is in flight or hanging. I wish my Character Controller (the capsule) is always close to Puppet even when he is in this state. it's possible to do it? Thanks
     
  38. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    BehaviourPuppet normally keeps the character root following the puppet horizontally, but grounded vertically while the puppet is ragdolled. If you set "Ground Layers" to nothing, then it won't do the vertical part.
     
  39. Marseol

    Marseol

    Joined:
    Jan 16, 2022
    Posts:
    10
    I set the ground, but when my character grabs the wall I have this problem of the Character Controller, falls to the ground. Is there a way to fix this behavior?
     
  40. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Oh, I totally forgot.. There's BehaviourPuppet.canMoveTarget (in the latest version). You can disable it, then you'll get 100% control over moving the character controller and BehaviourPuppet will never touch it.
    So for example in LateUpdate while behaviourPuppet.state == BehaviourPuppet.State.Unpinned:

    puppetMaster.targetRoot.position += puppetMaster.muscles[0].transform.position - puppetMaster.muscles[0].target.position;

    That would move the character controller so that the pelvis of the character matches with the pelvis of the ragdoll.

    Best,
    Pärtel
     
  41. ynm11

    ynm11

    Joined:
    Jul 6, 2021
    Posts:
    57
    Could PuppetMaster dynamically respond to mesh cutting? Like if a limb gets cut off with a system like
    , would the body movement from PuppetMaster know about it and react?
     
  42. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Hi there,

    Any extra setup required to use the broadcaster.Hit when the Time.TimeScale is not 1? I've found that the impulse is not having effect when in slowmotion. ie. A shot from the back in realtime sends the target forward with the impact but in slowmotion it falls back and is more visible the death animation that would be fading witht the coroutines used in the examples to fadeout pin and muscle weights.

    Any idea? Thanks a lot!.

    EDIT: Ok, i think it was a matter of set the animator to Unscaled time. No exactly the same but now it looks better and falls in the right direction. In any case, any tips in this would be great!
     
    Last edited: Jan 29, 2022
  43. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,556
    Hey,
    No, I don't think you could easily make that work with PM. If you slice a leg bone in half, it would probably want to create 2 rigidbodies of that leg bone, but that would mess up PM hierarchy and setup. You'll need to make sure you cut the mesh only at where the existing joints are and use PuppetMaster.DisconnectMuscleRecursive() to take care of cutting the joints. But you'd also have to make sure the mesh part that flies away doesn't have any bone weights to any of the remaining bones or you'll get mesh stretching from bodypart A to B. Also the mesh part that remains must not have any bone weights to the bones that fly away.

    Hey,
    With Unscaled Time you get worse physics quality in slow motion.
    Say you had a 1 sec animation and fixed delta time at 0.02, that would normally be 50 physics steps for that animation clip.
    If you set time scale to 0.1 and update mode to Unscaled, you'll only get 5 physics steps for that same animation because animation plays at the same speed, but physics frequency in slowed down by time scale.

    Best,
    Pärtel
     
    Danirey likes this.
  44. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Thanks for the aclaration. I'm now trying to implement explosions and add forces ( real time:) ) to the ragdolls. Any speceific treatment or can i go straight to the rigidbody addexplosionforce to all the rigidbodies, or selected ones in my case. I'm trying to get cool blow ups but the characters need thousands of explosion force to fly like they should.

    Best regards!
     
  45. WonkyDonky

    WonkyDonky

    Joined:
    Aug 24, 2014
    Posts:
    65
    @Partel-Lang Having a wierd issue in 2021.2:

    Using Biped ragdoll creator seems to work fine except the limbs bend wrong, but once I set up Puppetmaster and press playmode, character glitches for few frames and then the arms and legs bend inward:


    If I have "Support Translation Animation" checked, the hands and legs go normal, but it still glitches out for the first couple of frames like in the gif

    What is going on? None of the bones have any translation animation + If I uncheck "Support Translation Animation" while in playmode the hands and legs stay normal

    Doesn't happen with 2020.3, is this a known issue in 2021.2?
     
    Last edited: Feb 5, 2022
  46. gliealonso

    gliealonso

    Joined:
    Oct 21, 2018
    Posts:
    117
    Just updated my Puppet Master, and the same is happening to me.


    Another issue.

    Character hands is not following the propmuscle after PuppetMaster update.
    upload_2022-2-6_0-37-15.png
    upload_2022-2-6_0-37-48.png

    And everytime I spawn a character, this error appears "Inertia tensor must be larger than zero in all coordinates".
    upload_2022-2-6_0-38-22.png


    Could you please help?

    Thanks again Partel!
    Gabriel.
     
  47. gliealonso

    gliealonso

    Joined:
    Oct 21, 2018
    Posts:
    117
    Having some issues with the VRIK as well.

    Hands are getting inside the arms of the player model. And the elbows are in a weird position, and sometimes knees point out.

    upload_2022-2-6_15-15-39.png
    upload_2022-2-6_15-16-6.png
    upload_2022-2-6_15-16-33.png upload_2022-2-6_15-16-48.png
     
  48. gekidoslayer

    gekidoslayer

    Unity Technologies

    Joined:
    Sep 27, 2016
    Posts:
    134
    Had the same issue as this in 2021.2.10f1 , and checking 'Support Translation Animation' does seem to fix it! (whatever that does)
     
  49. WonkyDonky

    WonkyDonky

    Joined:
    Aug 24, 2014
    Posts:
    65
    @Partel-Lang Here's some physics changes that Unity made in 2021.2, maybe one of them is causing this issue:

    Physics: Adjusted anchor position based on anchor/parentAnchor transforms to better fit the expected result

    Physics: Prevented the ConnectedAnchor to be detected as property modification when AutoConfigureConnectedAnchor is set and ConnectedAnchor gets a generated value than happens to be different than the corresponding ConnectedAnchor value in the prefab.

    Physics: Fixed Rigidbody.angularVelocity setter that constrained the velocity wrongly; it's now doing it in mass-space to match what should happen actually.
     
    hopeful likes this.
  50. codedotart

    codedotart

    Joined:
    Sep 19, 2015
    Posts:
    13
    Hi,

    Thank you for making this asset. I tried submitting a support ticket but the Captcha verification keeps failing for some reason. Anyways I am using puppetmaster with the Ultimate Third Person character controller. It's a platformer like the fall guys game. So when the character is knocked out of the platform, I have placed a collider below the platform, and when the character collides with the platform and I am calling the ImmediateDeath() function of UCC, to initiate a respawn to the respawn location. But I think the ragdoll is not transporting with the character and the character is not getting respawning properly. What should I do to re-align the ragdoll so the respawn works properly?