Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

PuppetMaster - Advanced Character Physics Tool [RELEASED]

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

  1. Braxen

    Braxen

    Joined:
    Nov 17, 2018
    Posts:
    2
    Thanks for the response. The way I tried doing it was to first set up a custom rig with final ik, as you did in your mech spider video using rotation limit hinge. I only did this with the legs of a spider model. I then selected the main top parent object in the hierarchy and tried the Gameobject/Convert to ConfigurableJoints, which did nothing with the rotation limit hinges. Am I doing something wrong?

    I'm using 2019.4.25f1
     

    Attached Files:

  2. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,521
    Ah,
    Convert to ConfigurableJoints doesn't convert rotation limits, it converts other PhysX joint types to ConfigurableJoints.
    It was added because ConfigurableJoint setup can be a lot more confusing than say CharacterJoint setup. So people could setup their ragdoll with CharacterJoints or HingeJoints, then run Convert to ConfigurableJoints to make it work with PuppetMaster that requires all joints to be ConfigurableJoints.

    So in order to make you spider work with PuppetMaster:
    1. Add Rigidbodies, Colliders and Joints (HingeJoint, CharacterJoint or ConfigurableJoint)
    2. GameObject/Convert to ConfigurableJoints
    3. Add PuppetMaster
    4. Set PM layers, click on "Set Up PuppetMaster".

    Best,
    Pärtel
     
  3. gliealonso

    gliealonso

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

    I made a video of a question I have, and basically is how would I reuse a puppetmaster?


    Many thanks,
    Gabriel.
     
  4. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,521
    Hey,
    The ideal solution (but probably requires the help of a 3D artist) would be for all your characters to share the same skeleton, but have multiple SkinnedMeshRenderers, all included in the same FBX. That way you could switch between characters simply by activating/deactivating the skins.

    If that is not an option, there are 2 other ways.

    A) Build your puppets by script at Start. By that I mean doing ragdoll and PM setup 100% by script when the game starts. Take a look at "Creating Ragdolls In Runtime" and "Creating Puppets In Runtime" demos and scripts. That is what I normally do myself. You'd also need to use pooling then as all that setup in runtime has a CPU cost and you wouldn't want to run it every time you spawn in a new character mid-game. But pooling is always a good idea anyway. As a positive side-effect, if you ever plan to add support for modding, you'll already have the code to setup arbitrary character models as puppets.

    B) Write an editor script to automate the process of character replacement similar to ReplacePuppetModel in CharacterPuppetInspector.cs.

    You could also use PuppetMasterHumanoidConfig (ScriptableObject) to sync all the PM parameters, check out the "Humanoid Config" demo.

    Why your attempt at replacing the puppet in the video didn't work is that PuppetMaster requires the ragdoll and the animated hierarchies to be identical and those 2 skeletons probably had different bone orientations and stuff.

    Best,
    Pärtel
     
    OmnifariousStudios likes this.
  5. Doomchecker

    Doomchecker

    Joined:
    Apr 5, 2021
    Posts:
    105
    Unity 2020.3
    Puppetmaster newest version
    Default "BehaviourPuppet" in Behaviours

    Hi there,
    two beginner questions which I think are related. I went through the docs and forum but couldn't find something helpful. Sorry if I missed something obvious.

    1) I can't get the Individual Muscle Settings in the PuppetMaster component to work. I can set every value of every muscle to zero with no effect at all for the character. What am I missing?

    2) I love the PinWeight variable, gives a nice effect e.g. when health goes down. But for some reason, the arms of the character are jittering and a bit offset to the side as soon as I reduce the value below 1.
    Is there something I can do? If not I would be ok if I could just disable the arms for Puppetmaster but I can't (see question 1)

    Here a GIF with 0.9 PinWeight.
     

    Attached Files:

  6. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,521
    Hey,
    1) Maybe BehaviourPuppet's "Normal Mode" is set to "Unmapped"? In that case mapping is disabled until there is a collision with something on the "Collision Layers". After the collision is resolved, mapping is disabled again.
    By mapping I mean mapping the animated character to the ragdoll.

    2) I saw your question on the other thread too, there's something definitely wrong with those arms, but can't tell what it is from here. Does it change if you disable Angular Limits and/or Internal Collisions in PuppetMaster?
    Or maybe the arms are on a layer that collides with the character controller capsule?
    If you could send me a repro project or something I could take a closer look at here, I'd probably spot it in no time.

    Best,
    Pärtel
     
  7. Doomchecker

    Doomchecker

    Joined:
    Apr 5, 2021
    Posts:
    105
    Ahh ok so the 2 questions are related. I set it to "Unmapped" because when I enable it, I get the behaviour you see in the GIF. Now I realize it is the same problem.

    I just tried 3 times to export the scene but coudn't get it to run after importing again in another. Would probably be a waste of your time anyways because it's more of a tutorial project and there's a lot of stuff from the asset store inside.

    Maybe a hint for the behaviour:
    For the character I am using Opsive's Ultimate Character Controller and I am also using Final IK. I installed all the integrations (Final IK - Puppetmaster & UCC - Final IK & UCC - Puppetmaster) and put all UCC related update loops inside Update() to avoid jittering with UCC - Final IK I had before.

    So this probably IS an Update() Loop related problem?

    I know there are problems using the 3 assets together. Opsive has a new integration on their To-Do List.
     

    Attached Files:

  8. baixiaofei567

    baixiaofei567

    Joined:
    Jul 20, 2021
    Posts:
    1
    Hello, I have a question, we used animation and force to affect the PM skeleton in FixedUpdate, and then in LateUpdate since the PM skeleton is affected by both animation and force, which in turn affects the skin skeleton (animated skeleton), then at the end of this frame, the skin skeleton will be different from the original. If the skeleton is not restored to its original position at the beginning of the next frame, it will affect the PM skeleton in this position again and again, and finally the gap between the skeleton and the original animation will become larger and larger. How did you solve it?

    If you can guide me, I will be very grateful.
     
  9. Deleted User

    Deleted User

    Guest

    Hey Partel,

    I recently used the same setup for my characters now the 3rd time with Puppet Master, it's just the best setup I can come up with ... however, I never really solved this bug on all character controllers I've made, it's not 100% Puppet Master Related but sometimes Physics go wild on bad frame rates or spikes of the CPU where Delta Time get corrupted.

    I like to know what's the best way to "Track" this error how could I possibly check this situation through code when the colliders are stuck in a wall?
    More in the Video

    My plan is to reset the muscles when this happens but I have no idea how I can track it in a good way.

    Kind regards flow
     
  10. gliealonso

    gliealonso

    Joined:
    Oct 21, 2018
    Posts:
    114
    Hi Partel! Thanks for the reply!
    I liked the option A, but how would that work for a complex game? Do you have images with a few examples?

    Many thanks,
    Gabriel.
     
  11. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,521
    Hey,

    Sorry, it is very difficult to guess without being able to play around with a repro. I'd try disabling things one by one, maybe try disabling Final IK stuff, maybe there is some Opsive IK stuff going on with the arms too. I'm curious why it is only the arms that have this problem, that's why I'm thinking it might be related to IK or some other procedural adjustments done on the arm bones, that are probably being done at the wrong time in the update loop.
    If the arms stop jittering when you set Animator update mode to Normal, it's probably some IK being applied in LateUpdate every frame while it should be only applied if a FixedUpdate has been called earlier that frame.

    Hey, just replied to your e-mail.

    Hey,
    Just an idea, but you could monitor joint.currentForce.sqrMagnitude for some of the joints. CurrentForce is the force applied by the physics solver to satisfy all constraints and when a collider is stuck, it returns large values.
    So if currentForce.sqrMagnitude is above a certain threshold (probably about a million or so) a few FixedUpdates in a row, it should be safe to assume the ragdoll is stuck.

    Hey,
    The examples I have are CreateRagdollInRuntime.cs and CreatePuppetInRuntime.cs. The rest of the process is so specific to each game and each character, I can't really make a generic example.

    Best,
    Pärtel
     
    gliealonso likes this.
  12. Deleted User

    Deleted User

    Guest

    Works perfect, I did change the tracking from sqrMagnitude to the usual Magnitude because sqrMagnitude was pretty close to float.MaxValue which I found a bit too risky, I tracked a magnitude of 2500 and get out of 10 frames an average force and when the average force is higher than 5000 I just move all muscles to the target which is in my case always on the ground level because my controller is structured that way ...


    Thanks very much for this suggestion!

    All the best Flow
     
    Partel-Lang likes this.
  13. Julius48484

    Julius48484

    Joined:
    Apr 9, 2017
    Posts:
    3
    Hey Partel,

    I'm a relative novice when it comes to Unity, I can read code and get it if its not too complex and I stare at it for 15 mins.

    I have been through the Puppetmaster documentation and YouTube tutorials, as well as going through the demo scenes in the package.

    I have a question about how to initiate Puppetmaster behaviours. I can see in several of the demos where the Behaviour is initiated by pressing a key how it works in code. I can also see how the Falling demo works as well, and you spell it out in the read me file.

    The one demo I spent time with but didn't understand how the Puppetmaster behaviours is being initiated was the "Melee" demo where you could whack a bear and a soldier (very therapeutic by the way). In that demo you state in the Readme:

    "This scene demonstrates how 2 or more puppets controlled by the BehaviourPuppet act on collisions and how actions like punching or hitting with a bat could be designed."

    The problem is I can't work out how this is setup. I have been through the code and I believe using the Action system when a player presses the hit key, it does the Hit action which gives a punch animation. Is there anything Im missing in the code that goes with the Hit action?
    How is the Bot Puppet being knocked down? Is it just from the collision with the player rigidbody? Is the Hit action initiating the Bot Puppet's unpinning of their Puppetmaster in the same way as when the player character runs into the Bot Puppet? Is it all just based on the Player character moving into the Bot Puppet at speed?

    Sorry if I missed something obvious, and thanks for the awesome system.

    Jules
     
  14. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,521
    Hey,
    Yeah, the hit action is triggered when you press the hit key. That just makes the pilot play the hit animation, the bots are knocked down just from the collision, there is nothing else going on really. Just 1 thing though, the Booster is used there. Booster gives temporary immunity from collision damage and/or collision impulse multiplier to the pilot when the hit is triggered, so that gives a little bit of extra punch to the hits prevents the pilot from getting unpinned by his own hit. You'll see the Booster when you expand the melee Actions.

    Best,
    Pärtel
     
  15. FaffyWaffles

    FaffyWaffles

    Joined:
    Apr 10, 2020
    Posts:
    45


    So I'm having a bit of trouble with some custom mesh colliders. The hips, spine, and legs are working perfectly fine. But for some reason, the shoulders and arms refuse to allow collisions with each other. I've fixed this before by messing with the hierarchy, and by turning off the self collisions. But I'm doing something that requires the self collisions, and requires the hierarchy to remain intact. Is there any way to fix this that you know of?
     
  16. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,521
    Hey,
    Could you please send me that character fbx and the puppet prefab as a unitypackage so I could take a closer look?

    Just wandering, is there a specific reason why you need such high definition ragdoll, I mean with all the neck, shoulder and toe bones included? Thing is, PhysX is quite bad at handling long joint chains, the ragdoll actually gets less stable with every joint you add so more rigidbodies doesn't necessarily mean more accurate/better simulation. In most cases it just means considerably slower performance and sometimes wacky results.

    Also, MeshColliders are pretty expensive too, might want to try compound colliders instead (multiple child gameobjects with primitive colliders) if you need very accurate collision geometry.

    Best,
    Pärtel
     
  17. Ercova

    Ercova

    Joined:
    Oct 21, 2019
    Posts:
    4


    Hello Partel-Lang.
    I have a problem seen in the video. Character jump and fall with the standart character controller gravity Unity suggested. Can you take a look at it please?
     
  18. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,521
    Hey,
    Maybe the character controller's layer is set to ignore that floor object's layer in the Layer Collision Matrix?

    Best,
    Pärtel
     
  19. ferverence

    ferverence

    Joined:
    Jul 15, 2014
    Posts:
    56
    Hello, I have a ragdoll puppet character which is currently animated to play piano (just playing arbitrarily not along with the music in code). However in code I have the specific keys that are being played with music. I'm thinking that I could use Final IK to move the hands programmatically and the arms would follow, correct? So this way the character is playing accurately. I do not have Final IK but asking to see if this use case would be viable. Thanks!!!

    edit: Actually it looks like I can just use a kinematic RB with joint I believe.
     
    Last edited: Aug 24, 2021
  20. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,521
    Hey,
    You can use a kinematic RB with a joint, but you'll have to set pin weight to 0 for all the arm muscles to allow them to depart from the animation and follow those rigidbodies.

    Can do it with FIK too.

    Best,
    Pärtel
     
    ferverence likes this.
  21. a_engel123

    a_engel123

    Joined:
    Dec 25, 2020
    Posts:
    4
    Hello,
    I've been trying to use Unity's starter assets character controller with puppet master, and I've encountered a problem. Whenever the character moves sideways (perpendicular to the camera) there is a lot of jittery motion. This is not present when the player moves towards or away from the camera. The camera is set up using cinemachine 3rd person follow, with the rotation handled in LateUpdate. I went through and set all the rigidbodies to interpolate, but there still seems to be the jitter. When puppetmaster is set to Kinematic or disabled, however, the jitter is greatly improved. Below are some screenshots of what I have set for the rigid bodies and the puppet master. Is there any known fix for this?
     

    Attached Files:

  22. imaginationrabbit

    imaginationrabbit

    Joined:
    Sep 23, 2013
    Posts:
    349
    I wonder if this is the first time Puppetmaster has been credited as a stuntman? :D




    We recently made a strange animated feature film with our game "Nightmare Puppeteer" which uses Puppetmaster and decided it was appropriate to credit Puppetmaster for stunts- you can see the film here
     
  23. Ceryni_

    Ceryni_

    Joined:
    Apr 20, 2020
    Posts:
    7
    Hi,
    i'm trying to set up the puppetmaster for a character but i ran into two problems. first was that the prefab lost the connection to the sourcefile when creating the puppetmaster. (the blue icon turned to a grey one)
    I tried to fix this by creating the puppetmaster on a duplicate of the character and link the joints and target root of the intact object to the puppetmaster.
    is there a better way to do this?
    second problem is when i start the scene i get an error that the spine muscle position does not match with its target. i tried the fix muscle positions button but it did nothing. they have the same world position. only their local position is different. do you have an idea what i did wrong?
    sorry if i'm missing something obvious here.
     

    Attached Files:

  24. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,521
    Hey,
    The camera needs to be updated at LateUpdate, but from a script that has higher value in the Script Execution Order than PuppetMaster has. Haven't tried Cinemachine, can you change it's execution order value?

    Hahaha, you are crazy! But I loved it, could not stop watching :D
    I appreciate the credits too!

    Hey,
    The way to setup PM without breaking prefab connections is like this:
    1. Add a new model instance to the scene.
    2. Setup ragdoll on the new model. If you already have a ragdoll done and don't want to redo, can use what you already have instead of the new model. Just break the prefab and nuke all components except for the Animator.
    3. Add PM to the new model
    4. Assign the original model as "Animated Target"
    5. Set layers and click on "Set Up PuppetMaster".

    The other problem might be related to the problems with the setup, please try the solution above.

    Cheers,
    Pärtel
     
  25. a_engel123

    a_engel123

    Joined:
    Dec 25, 2020
    Posts:
    4

    I don't think you can change its execution order directly. Is there a way to change the execution order for puppetmaster? I tried changing the order in "project settings" but the puppet master script kept returning to its original position once the settings were applied.
     
  26. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,521
    Hey,
    PM SEO is hardcoded in PuppetMasterInspector.cs line 38. You can change it to earlier, but if you also use Final IK and change PM to update before FIK components, you'll have to disable the FIK components in Start and update them via ik.solver.Update() from PuppetMaster.OnRead delegate.

    Best,
    Pärtel
     
  27. daedal

    daedal

    Joined:
    Dec 19, 2013
    Posts:
    31
    Hey @Partel-Lang,

    With the default PuppetMaster and BehaviourPuppet settings, I'm getting some extreme behavior with impacts from larger objects and a too rapid recovery from smaller impacts. I'm using trigger colliders with these objects and calling MuscleCollisionBroadcaster.Hit in OnTriggerEnter to affect the ragdoll. The larger objects are using similar inputs but affect more MuscleCollisionBroadcasters. (I'm using trigger colliders because these objects are not solid)

    Here's what the extreme behavior looks like a moment after the impact. How do I prevent the bones from being stretched?

    RagdollBug.PNG

    With the smaller impacts, the character will revert to the normal animation in a tiny fraction of a second. If the character gets hit in the shoulder for example, I want it to take about a second before the character's shoulder recovers to the animation position. I've tried tweaking some of the settings like the pin weight and the muscle strength. I didn't find any settings that worked though and would often end up seeing some oscillations when I did get some slower recoveries to the animation position.

    Also for these impacts, I'm not looking to do anything that would cause the character to lose balance and be knocked down. I'll add specific abilities that allow for that at a later time.

    Do you have any tips on what I can do to resolve these issues?

    Thanks!
     
  28. InfinityGameDev

    InfinityGameDev

    Joined:
    Jun 28, 2016
    Posts:
    47
    Hi Partel, I wasn't able to find a good answer for this but it's probably easy. How do you add a new animation to the third person controller with movement? For example I'm using the strafe move mode but when I add a running animation the player just runs in place. I figure it has something to do with root motion but I couldn't find a place to change it in the scripts.

    Thank you!
     
  29. jens_unity858

    jens_unity858

    Joined:
    Nov 26, 2019
    Posts:
    17
    Hi Pärtel,

    How do I override projection mode after puppet master initiates?

    (nevermind I found your answer in this thread: "look for joint.projectionMode = JointProjectionMode.None; in Muscle.cs" )
     
    Last edited: Sep 9, 2021
  30. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,521
    Hey,
    How much force were you adding with that hit? Looks like the ragdoll is just being torn apart by the forces. In Unity2019.3 and later you are able to set solver type to Temporal Gauss Seidel in Physics Settings. That is a new much more stable joint solver that could prevent this from happening. Another thing to try would be to set the force vector you pass with broadcast.Hit to zero and foreach all puppetMaster.muscles instead and add some of that force to other rigidbodies too, so it wouldn't be just 1 rigidbody to be blown away.

    About the smaller impacts.. Adding some drag to the puppets can help with recovering slower/smoother. Try this little script>
    Code (CSharp):
    1. using UnityEngine;
    2. using RootMotion.Dynamics;
    3.  
    4. public class PuppetDrag : MonoBehaviour {
    5.  
    6.     public BehaviourPuppet puppet;
    7.     public float drag = 5f;
    8.     public float angularDrag = 5f;
    9.  
    10.     private bool lastWasPinned = true;
    11.  
    12.     private void FixedUpdate()
    13.     {
    14.         // Unpinned state, do not apply drag
    15.         if (puppet.state == BehaviourPuppet.State.Unpinned)
    16.         {
    17.             // Optimization
    18.             if (lastWasPinned)
    19.             {
    20.                 foreach (Muscle m in puppet.puppetMaster.muscles)
    21.                 {
    22.                     m.rigidbody.drag = 0f;
    23.                     m.rigidbody.angularDrag = 0.05f;
    24.                 }
    25.                 lastWasPinned = false;
    26.             }
    27.  
    28.             return;
    29.         }
    30.  
    31.         // Calculate drag based on how much muscle pin weights damaged by hits/collisions
    32.         foreach (Muscle m in puppet.puppetMaster.muscles)
    33.         {
    34.             m.rigidbody.drag = Mathf.Lerp(drag, 0f, m.state.pinWeightMlp);
    35.             m.rigidbody.angularDrag = Mathf.Lerp(angularDrag, 0f, m.state.pinWeightMlp);
    36.         }
    37.         lastWasPinned = true;
    38.     }
    39. }
    It basically adjusts rigidbody drag based on how much muscle pin weights are damaged by hits/collisions.
    In addition to that, "Regain Pin Speed" in BP, "Pin Pow" and "Muscle Damper" in PM have an effect on that.

    If you want puppets to not fall until you tell them to, set behaviourPuppet.knockOutDistance to Mathf.Infinity at Start.

    Hey,
    Do those animations that you added have any root motion? I'm guessing not. Or maybe you have "Bake Into Pose" under "Root Transform Position (XZ)" in the animation import settings of those clips?

    Best,
    Pärtel
     
  31. alsomitra

    alsomitra

    Joined:
    Aug 31, 2017
    Posts:
    33
    Hey, @Partel-Lang

    I'm trying out Stagger(Puppet & Stagger my character) .
    Note that I have applied all the patches.
    https://rootmotion.freshdesk.com/support/solutions/articles/77000484277-patches

    I've noticed that sometimes he stays bent over and can't get up.
    Sometimes he floats in the air and bends down (looks like he's sitting normally).
    Sometimes they are bent over lying on the ground (not face down, not on their back).

    When I observe the event, it is as follows

    BehaviorBipedStagger.enabled false;
    and()
    Stagger: OnFinishied

    BehaviorPuppet.enabled true;
    and
    Behavior Puppet: On Regain Balance

    Is there anything I can do to fix this?

    ------
    Addendum:

    If I create a new project, the problem does not occur.
    If I apply the above patch, the problem occurs.

    I have recently applied the patch, but the problem next occurred even without the patch.

    I've noticed that sometimes he stays bent over and can't get up.
    Sometimes he floats in the air and bends down (looks like he's sitting normally).
    Sometimes they are bent over lying on the ground (not face down, not on their back).

    Thank you very much.
     
    Last edited: Sep 22, 2021
  32. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,521
    Hey,
    Switching behaviours is not supposed to work by clicking that enabled box in editor, call behaviourPuppet.SetState(BehaviourPuppet.State.Unpinned); instead and PM will properly switch to the behaviour that BehaviourPuppet has in the "On Lose Balance" event.

    Best,
    Pärtel
     
  33. alsomitra

    alsomitra

    Joined:
    Aug 31, 2017
    Posts:
    33
    Thank you.
    I will do as you suggest.
    I'm not using a standalone Stagger, but the standalone Stagger seems to behave strangely when patched.
     
  34. Bamboidski

    Bamboidski

    Joined:
    Oct 26, 2019
    Posts:
    8
    Hi, I have a problem with PupperMaster when loading scenes. Sometimes I get naaaasty crackens, characters fly away with arms and legs spaghetified in different directions and then land somewhere in the distance.

    Is there a way to fix it?
     
  35. graphicsayy97

    graphicsayy97

    Joined:
    Dec 24, 2020
    Posts:
    50
    hello dev amazing work on this asset

    how is it we make similar armature and empty (no mesh) rig "cowboy animation target"?

    im learning disconnecting muscles example for my own dev, from i understand it, the script "skeleton" can be apply to any models?

    when making blender im getting issues for import (no mesh data) and fbx export from unity wont export the "empty mesh" rig only..... maybe just problem for me

    is anything special for it beyond calling the script and storing reference to puppet master with muscle for object?

    must i always use empty rig and match it with mesh per limb??
     
  36. J0linar

    J0linar

    Joined:
    Dec 12, 2013
    Posts:
    83
    Hi @Partel-Lang just recently more or less i started playing around with puppetmaster and FinalIk..
    First of all let me bow to you, what an awesome product/s

    Was wondering how i could accomplish the following with it.


    +Grab a puppet with FinalIk/Vrik
    +making the puppet Fall depending on where you push it towards


    and sry if this was asked before and thx
     
  37. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,521
    Hey,
    Weird, I can't see that happening here. Maybe that patch you had is outdated, I just uploaded the latest to this link.

    Hey,
    Haven't seen that one before.. Are your puppets under DontDestroyOnLoad or are you instantiating them from prefab or do they belong to the scene?

    Hey,
    I made that model 10 years ago, I'm afraid the source files have gone missing.
    Yes, the skeleton script can apply to any model, all it really does is play the hopping animation when a leg is removed and kill the puppet when both legs are removed.

    You don't have to use the CowboyAnimationTarget at all. If you have a model in Blender and that model has an armature, export it to Unity like you normally would. Just parent all bone meshes to their respective bones. The rest of PuppetMaster setup process is the same as it is for a skinned mesh model.

    Hey and thanks!

    There is a demo about grabbing puppets, it's called "Melee Grab". In that demo there is no IK for moving the hand to the other puppet, it just connects the hand rigidbody to whatever ragdoll it collides with. But to create IK for that, can just add FullBodyBipedIK or ArmIK or LimbIK to the character, set it's hand target to what you wanna grab and blend in effector position weight. Just make sure to do it when standing close enough to the other puppet.

    Cheers,
    Pärtel
     
    graphicsayy97 likes this.
  38. graphicsayy97

    graphicsayy97

    Joined:
    Dec 24, 2020
    Posts:
    50
    thanks very much dev!

    i did what you said and it worked!

    now i have other issue with bone(armature) position on the import and setup for humanoid rig i used and armature create in blender itself, some time missing limb of empty armature on export to unity...confusing
     
  39. J0linar

    J0linar

    Joined:
    Dec 12, 2013
    Posts:
    83
    thx @Partel-Lang
    now i got a weird issue, that seems to happen when the puppt gets killed it starts to float above ground but continues to do its routine... might just be my own fault, messed up something or overlooked
     
  40. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,521
    Sorry, I'm not that familiar with Blender. Used to work with 3ds Max and Lightwave, but that was 7 years ago.

    Hey, did you already figure it out (on Discord) or was that someone else with a similar question?

    Cheers,
    Pärtel
     
    graphicsayy97 likes this.
  41. Rand_D

    Rand_D

    Joined:
    Oct 24, 2017
    Posts:
    43
    Hi Pärtel,
    I would like to ask if PuppetMaster can be used to set up active ragdoll movement ? Like the game Human Fall Flat where the character is clumsy and easy to fall. And the player will have to fiddle with movement to help the character stand up straight. Is there any example in the package to support this out of the box ?
     
  42. J0linar

    J0linar

    Joined:
    Dec 12, 2013
    Posts:
    83
    @Partel-Lang sry yes that was me.. this here is just my alterego^^
    and sry for not writin earlier but tbh i have never encountered such fast support!!!
     
    Partel-Lang likes this.
  43. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    506


    Hi, I mentioned your character animator culling mode is set on "Always Animate" but I get a lot more better performance when I set it to "Cull Completely"! I have 60 characters on my scene. Can I do that without any issue?
     
  44. InfinityGameDev

    InfinityGameDev

    Joined:
    Jun 28, 2016
    Posts:
    47
    Hi Partel, I've been having an issue that I can't figure out. I've attached a video here:


    I'm trying to do a simple explosion with this line:
    Code (CSharp):
    1.  col.transform.root.Find("Behaviours").Find("Puppet").GetComponent<BehaviourPuppet>().SetState(BehaviourPuppet.State.Unpinned);
    and add this after:
    Code (CSharp):
    1.  rb.AddExplosionForce(force,transform.position,radius);
    but it is causing the bug in the video. However if I use this line instead:
    Code (CSharp):
    1. col.transform.root.Find("PuppetMaster").GetComponent<PuppetMaster>().pinWeight = 0;
    it works perfectly. Unfortunately that creates other issues when it comes to resetting the pinWeight to 1.

    I was wondering if you knew how to fix this?

    Full code here:
    Code (CSharp):
    1.  Collider[] colliders = Physics.OverlapSphere(transform.position,radius);
    2.  
    3.             foreach (Collider col in colliders){
    4.  
    5.                 Rigidbody rb = col.GetComponent<Rigidbody>();
    6.  
    7.                 //turn off IK
    8.                 //Drop prop?
    9.  
    10.                 if(col.gameObject.name == "Hips"){
    11.                     // col.transform.root.Find("PuppetMaster").GetComponent<PuppetMaster>().pinWeight = 0;
    12.                     col.transform.root.Find("Behaviours").Find("Puppet").GetComponent<BehaviourPuppet>().SetState(BehaviourPuppet.State.Unpinned);
    13.  
    14.  
    15.  
    16.                     // behaviourPuppet.SetState(BehaviourPuppet.State.Unpinned);
    17.                 if(rb != null){
    18.                     rb.AddExplosionForce(force,transform.position,radius);
    19.                     Debug.Log("boom");
    20.                 }
    21.             }
    22.         }
     
  45. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,521
    Hey,
    I don't know exactly how HFF was made so can't be sure, but from the way it looks, I think it is using rigidbody and capsule collider for the character controller. The ragdolls are just connected to that and animated physically via muscles. So the self-balancing is not real, but faked with something similar to PuppetMaster's pinning forces.

    With PuppetMaster you could do something like that, for example if you went to the "Basic" scene, expanded the Muscles array on the bottom of PM and set "Pin Weight" to 0 for all the muscles except for the pelvis, spine (for keeping the body upright). Enable "Angular Pinning" to lock facing direction so the ragdoll doesn't just spin. Increase "Muscle Spring" to something like 200.

    You'd also want a Rigidbody and a CapsuleCollider or a CharacterController on the gameobject that has the Animator. That would be your character controller, you can add forces to the rigidbody to make the character move. Make sure that capsule doesn't collide with the ragdoll layer (Layer Collision Matrix).
    Then you'll just need to play some kind of walking animation in the direction you are moving with that character controller.

    To make the puppet fall, set PuppetMaster pinWeight to 0.

    It will look much better with blob-like characters with small legs and arms like HFF has.

    Hey,
    If you have "Fix Target Transforms" enabled in PM, then it should not be a problem to use Cull Completely. Otherwise PM mapping would get into a vicious cycle of additively reading/writing the pose frame by frame (with nothing overwriting it in between) and the ragdoll would eventually freak out.

    You might see a problem with fallen ragdolls stopping their animation. That would happen when physics moves the ragdolls out of their SkinnedMeshRenderer's bounds and the animation gets culled. So it might be a good idea to use "Always Animate" while behaviourPuppet.state == BehaviourPuppet.State.Unpinned and "Cull Completely" at all other times.

    Best,
    Pärtel
     
    Crossway likes this.
  46. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    506
    Ok thank you, I'll check this but for now I mentioned if I enable PuppetMaster on all 60 characters it reduces frame rates from 120 to 2 fps! I remember it wasn't like this before!
     
  47. Omnomnyan

    Omnomnyan

    Joined:
    Sep 1, 2013
    Posts:
    4
    Hey, i cant figure out what causing crazy jitter when mappingWeight in Puppetmaster is not equals 0 or 1.
    Animator is set to AnimatePhysics mode, im trying to smooth cull puppetmaster, when there is no collisions.
    Or maybe there is method or variable that stores current applied force to muscles?
    Was not able to locate any included method to check current *deviation* from animator.
     
  48. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,521
    Hey,
    With 60 active ragdolls in the scene, I'm not surprised the framerate is bad.. But it shouldn't be as bad as 2 fps. Maybe you had some object selected in the editor? That usually slows down fps by a lot in editor.

    Hey,
    Culling PM when there are no collisions can be done just by setting BehaviourPuppet's "Normal Mode" to "Unmapped" or "Kinematic".

    Best,
    Pärtel
     
  49. Omnomnyan

    Omnomnyan

    Joined:
    Sep 1, 2013
    Posts:
    4
    For sure, but with only one Puppet on scene Disabled mode is saving like ~0.2ms CPU comparing to Kinematic mode. What im trying to do is to lerp Mapping weight to zero if there is no colliders within overlapSphere and then set disabled mode. But while mapping weight is anything but 0 or 1 mesh is jittering crazy between two positions (animator and puppet). Lerp is required due to possible fast colliders that may collide with puppet and fly away from overlap sphere what will cause instant recover of animator no matter what impulse was made. Other possibility i see is to check when puppet (not knocked out) is recovered pin and set it to disabled, but i wasnt able to locate any methods yet

    UPD: nevermind, just added some code in BehaviourPuppet fixedUpdate:
    In foreach Muscles
    Code (CSharp):
    1. currentPinMedian += Mathf.Clamp(m.state.pinWeightMlp, 0F, 1F);
    2. currentPinsCount++;
    And after
    Code (CSharp):
    1. currentPinMedian = currentPinMedian / currentPinsCount;
    But not sure about performance :D
     
    Last edited: Oct 4, 2021
  50. rastleks

    rastleks

    Joined:
    Jul 17, 2014
    Posts:
    43
    Hi. Trying to make Puppet Behaviour work properly with particle collisions.

    The problem is that Puppet Behaviour didn't handle particles collision so I think because of this unpinning doesn't work properly.

    Only way it works is by knock out distance.

    In demo scenes Pin Weight for puppet master is 1.0, but in this case puppet doesn't react to particles collisions.

    In case I make it, for example, 0.6, it start working but if loose balance on start.

    How I can fix this "loose balance on start" issue? Current workaround is to start with pin weight 1.0 and lower it smoothly in a first few seconds to 0.6. But I don't think that this is the best way to do it.

    May be I can somehow simulate collisions by code?
     
    Last edited: Oct 11, 2021