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:
    1,908
    Hey,
    Oh, I see, you are using BehaviourBipedStagger, didn't notice that in the gif. In that case, the Muscle Weight values probably need to be reduced to loosen the arms a bit. And lower the "Unbalanced Muscle Weight Mlp". Also decrease the "Max Angle".

    Hey,
    Acutally just very recently I've found that the most performant way to cut limbs would not be to use RemoveMuscleRecursive at all, but just change some joint settings and muscle props, like this:

    Code (CSharp):
    1. m.joint.xMotion = ConfigurableJointMotion.Free;
    2.         m.joint.yMotion = ConfigurableJointMotion.Free;
    3.         m.joint.zMotion = ConfigurableJointMotion.Free;
    4.         m.joint.angularXMotion = ConfigurableJointMotion.Free;
    5.         m.joint.angularYMotion = ConfigurableJointMotion.Free;
    6.         m.joint.angularZMotion = ConfigurableJointMotion.Free;
    7.         m.props.pinWeight = 0f;
    8.         m.props.muscleWeight = 0f;
    Also set pinWeight and muscleWeight to 0 for the child muscles of that muscle (can use muscle.childIndexes for that).
    And to put that muscle back:

    Code (CSharp):
    1. m.joint.xMotion = ConfigurableJointMotion.Locked;
    2.                 m.joint.yMotion = ConfigurableJointMotion.Locked;
    3.                 m.joint.zMotion = ConfigurableJointMotion.Locked;
    4.                 m.joint.angularXMotion = ConfigurableJointMotion.Limited;
    5.                 m.joint.angularYMotion = ConfigurableJointMotion.Limited;
    6.                 m.joint.angularZMotion = ConfigurableJointMotion.Limited;
    7.                 m.props.pinWeight = 1f;
    8.                 m.props.muscleWeight = 1f;
    So with that solution, there is no expensive recalculation done on the puppet hierarchy, just changing some joint parameters basically. I'll add that in as a proper feature in the next version probably.

    As for the skinning, you can hide the normal SkinnedMeshRenderer and enable the limbless or headless SkinnedMeshRenderer and also the cut off body part renderer.

    Best,
    Pärtel
     
    Subliminum likes this.
  2. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    731
    Thanks for the reply, I will definitely try that.

    You also bring up another good point though that I kept forgetting. It seems I don't really notice that it is using BehaviourBipedStagger most of the time either. A big part of my game I wanted to have was much more staggering (so they might stagger into traffic after getting something thrown at them or pushed, for example), but it seems as if at most I end up seeing nothing more than a slight wobble, or perhaps one step which then ends up being a complete knockdown instead of a stagger. I had copied the settings from the stagger demo but it seems as if it does not happen very often at all, and when it does, it is barely noticeable. Any recommendations on how to make it occur more often when I either push or throw something at them, or perhaps to make it... I am not sure, stronger, I guess? Perhaps, just less likely to go from normal to completely unpinned, so there is a bigger margin in which stagger might occur? I am fine with no stagger if they get full on hit by a vehicle, as that is not likely to cause much stagger, lol.

    Thanks again!
     
  3. Subliminum

    Subliminum

    Joined:
    Nov 9, 2017
    Posts:
    71
    Interesting stuff, ive already worked out skinning for the most part, so ill add this in and see how it goes.

    Thanks! :)

    EDIT: This is working nicely,
    Code (CSharp):
    1. /// <summary>
    2.     /// Method to toggle muscles attachment
    3.     /// </summary>
    4.     /// <param name="muscleIndex">Index of the Musle in PuppetMaster.muscles[]</param>
    5.     /// <param name="value">True to disconnect, False to Reconnect</param>
    6.     public void SeverMuscle(int muscleIndex, bool value)
    7.     {
    8.         Muscle rMuscle = rPuppet.muscles[muscleIndex];
    9.         rMuscle.joint.xMotion = value ? ConfigurableJointMotion.Free: ConfigurableJointMotion.Locked;
    10.         rMuscle.joint.yMotion = value ? ConfigurableJointMotion.Free : ConfigurableJointMotion.Locked;
    11.         rMuscle.joint.zMotion = value ? ConfigurableJointMotion.Free : ConfigurableJointMotion.Locked;
    12.         rMuscle.joint.angularXMotion = value ? ConfigurableJointMotion.Free : ConfigurableJointMotion.Limited;
    13.         rMuscle.joint.angularYMotion = value ? ConfigurableJointMotion.Free : ConfigurableJointMotion.Limited;
    14.         rMuscle.joint.angularZMotion = value ? ConfigurableJointMotion.Free : ConfigurableJointMotion.Limited;
    15.         rMuscle.props.pinWeight = value ? 0f : 1f;
    16.         rMuscle.props.muscleWeight = value ? 0f : 1f;
    17.     }
     
    Last edited: Jan 30, 2019
  4. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,908
    Hey,
    Have you set the mass of all your ragdoll rigidbodies to 1? Stagger behaviour default values were set up with that in mind, so heavier ragdolls might fail.
     
  5. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    731
    I just went to double check and make sure, it looks like all of them do have mass set to 1, drag 0, ang. drag 0.05, Gravity: Yes, Kinematic:No, Interpolate:None, Collision: Discreet, and Freeze Rot. XYZ: Yes to all 3.

    Update - I updated my entire project to 2018.3 and deleted PM and FIK and redownloaded and reimported them fresh and it seems that some things are better now, but some things are worse. I am going to spend some time tomorrow and look over everything and do some tweaking again with a few things you mentioned and see how things end up now after the update.

    Thanks for the advice!

    Update2 - It looks like the collisions in general look much nicer, for some reason the arms and what not seem to mostly have fixed themselves and I am seeing more staggering without my having changed any settings, just the 2018.3 update and updates to the assets. Perhaps some values got reset somewhere. One thing though I wanted to ask, after updating to 2018.3 I am still seeing a lot of activity here, is it still supposed to be like that?

    This is 2018.2.16f1



    This is 2018.3.3f1


    Then, you should be able to see in this below, nearly always at the top and all of those spikes were from the same thing.

    https://i.imgur.com/r9nRj5m.gifv

    Just wanted to make sure that this was still supposed to be normal?
     
    Last edited: Feb 1, 2019
  6. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,908
    Hey,
    You also have to enable "Reuse Collision Callbacks" in the Physics Settigs, that should drop GC Alloc from Physics.Contacts to 0.
     
    MostHated likes this.
  7. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    731
    Thank you! So much better! : D I was now able to have 40+ characters on mobile with no problems at all. It should all just come down to tweaking and preference now.
     
    Last edited: Feb 2, 2019
  8. joeee19

    joeee19

    Joined:
    Jul 14, 2012
    Posts:
    43
    Hey.
    I want to switch character in Ragdoll state from script, and switch from Behavior to Active to kinematic.
    And soon I want to animate Rolling.


    Code (CSharp):
    1.  
    2. pmBehaviour.SetState (Behavior Puppet.State.GetUp);
    3. playerAnimator.Play ("NinjaRoll");

    But switching does not switch the mode of PuppetMaster Component to kinematic.

    Is there a way?
     
  9. farzaan090

    farzaan090

    Joined:
    Jul 23, 2018
    Posts:
    15
    When using props with Puppetmaster, maybe I'm setting things up wrong but whenever I set the puppet to "Unmapped" under the Normal Mode setting via the Behaviour Puppet script, the colliders that follow the prop no longer follow and match up with the mesh location of the prop.

    Is there any way to fix this or is this just a setup problem on my behalf?


    Separately, is there any way to access the Puppetmaster ragdoll layer for a non-puppet master object? What I mean is, I have a weapon that attaches itself to the character and has a layer of playerAttacks. I allow playerAttacks to collide with the ragdoll layer as I want it to hit other PM ragdoll entities. However, this now causes collisions between the PM colliders on the entity holding this weapon and the weapon. Am I able to ignore these collisions on the entity holding the weapon?
     
  10. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,908
    Hey,
    PuppetMaster is forced to Active in GetUp state because it needs to blend from ragdoll to animation during that state and that can't be done in Kinematic mode, as in that the ragdoll is snapped to the animation.
    You should set state directly to Puppet and then set PM to Kinematic:
    Code (CSharp):
    1. puppet.SetState(BehaviourPuppet.State.Puppet);
    2.             puppet.puppetMaster.mode = PuppetMaster.Mode.Kinematic;
     
  11. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,908
    Hey,
    In Unmapped mode the colliders rarely match up with the mesh. That is because the puppet is unmapped until there is a collision, but PuppetMaster is still active and trying to follow the animation, but that is never 100% accurate. Unmapped mode was designed to let you have full animation accuracy until there is a collision, after which mapping is blended in, the collision is resolved and then mapping blended out again.

    About the other question about the layers, yes, you could either have "Internal Collisions" disabled in PuppetMaster, or do this when the weapon is picked up:

    Code (CSharp):
    1. foreach (Muscle m in puppetMaster.muscles) {
    2. foreach (Collider c in m.colliders) {
    3. foreach (Collider wC in weaponColliders) {
    4. if (c.enabled && wC.enabled) {
    5. Physics.IgnoreCollision(c, wC);
    6. }
    7. }
    8. }
    9. }
    Or just make new layer "PuppetProp", make it ignore the ragdoll layer and move the weapon to that when it is picked up.

    40+ characters? Which mobile device was that? :)
    You'll probably see the performance drop when they all run into each other, because of the increasing number of collisions to process.

    Cheers,
    Pärtel
     
  12. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    401
    I thought I would mention a frustration I just ran into. I spent about 2 hours trying to figure out why one of my PuppetMasters was not initiating. All I could figure out was that the muscles were not being registered by PuppetMaster. I was led to PuppetMasterValidation.cs and the Debug.Log error:
    Debug.LogError("PuppetMaster has not been initiated yet."); This is what made me aware that PuppetMaster was not working correctly. But the debug.log gave no useful information. Why was it not initiating??

    After 2 hours of digging around, messing with prefabs etc. etc. it turned out I had accidentally moved the controller gameobject in my character hierarchy instead of the parent/root gameobject of the character when I was manually re-positioning my character in the scene. So the child controller transform was no longer at 0,0,0. Usually I am very very careful about making sure all child gameobjects including BehaviorPuppet, PuppetMaster and the Controller gameobject are all zeroed out when I hit play. Because I know PuppetMaster is super fragile if things aren't zeroed out at startup.

    I realized the problem, zeroed out the Controller transform, slapped my forehead and thought man what an idiot. I have to fix this.

    My solution was to add the following line of code as the 1st line in the Awake method in my Base controller class:
    Code (CSharp):
    1. transform.localPosition = Vector3.zero; //Zero out transform otherwise Puppetmaster will not be initialized
    Hopefully this will help someone else out.

    I would love to see a more descriptive debug.log message in PuppetMaster so if PuppetMaster does not validate, it checks the controller transform and if is not zeroed out, it let's the user know.

    Thanks
    Allan
     
    hopeful and MostHated like this.
  13. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    731
    I've been there. I like to think that the forehead slap physically solidifies the remembrance of what I just realized, lol.
     
    Subliminum likes this.
  14. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,908
    Hey,
    Thanks for the feedback! PM should actually warn you if the muscle positions do not match with their targets, I guess I should use Debug.LogError instead of LogWarning there as most projects are full of warnings and they are hard to notice. I'll make sure to add all kinds of checks for that kind of stuff to the next version to make it more reliable.

    Cheers,
    Pärtel
     
  15. Mikekan13

    Mikekan13

    Joined:
    May 30, 2015
    Posts:
    72
    So I am in the middle of creating my combat/damage system in my game and although I seem to have everything working decently well I have a strange bug where the ragdoll goes crazy sometimes.
     
    ehimimaru likes this.
  16. qzix13

    qzix13

    Joined:
    Dec 2, 2015
    Posts:
    4
    Hey,

    Is it possible to apply more force to point of contact when something hit a bone of the puppet?

    thanks.
     
  17. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,908
    Hey,
    It's a general ragdoll stability thing. Please see if there's anything in here that you can implement.
    Also, based on the video it looks like you might be adding a large force to only the one Rigidbody that the energy blast hits. That means the joint will have to apply a large force to satisfy the constraint and that can shoot the connected body past the ground collider or get the ragdoll tangled up in weird ways. Try doing this instead:
    Code (CSharp):
    1. foreach (Muscle m in puppetMaster.muscles) {
    2. m.rigidbody.AddExplosionForce(force, position, radius);
    3. }
    to apply part of the force to all the rigidbodies.

    Hey,
    Yeah, you can use the BehaviourPuppet.OnCollision delegate to get a call from BehaviourPuppet every time it collides with something and call AddForce in that.
    Or if it's a combat situation, you could use the Boosters.
    Define a public Booster booster; Fill it out in the Editor and call booster.Boost(puppet); when you need a certain muscle or muscle group to deal more damage to what it collides with and/or have immunity against damage.
    The boosting effect falls off over time, defined by "Boost Falloff" in BehaviourPuppet, so call Boost when you start the attack animation.

    Cheers,
    Pärtel
     
    qzix13 and hopeful like this.
  18. JacobDzwinel

    JacobDzwinel

    Joined:
    Dec 19, 2013
    Posts:
    16
    Hey Pärtel,
    I recently found strange bug in my game, I thought i have something wrong set in my project but I made a fresh unity project with latest puppet master and I was able to reproduce it there.

    I have two identical puppet characters from "Puppet" demo scene. One on the right has BehaviourPuppet Normal Mode set to Active, on the left set to Kinematic.

    I'm using line below to unpin my characters with simple raycast from camera

    Code (CSharp):
    1.      
    2. behaviourPuppet.SetState(BehaviourPuppet.State.Unpinned)
    3.  


    I disabled gravity on character rigidbodies and move them a little in the air. You can clearly see that character with kinematic mode is teleported on the ground after setting unpinned state.

    It's still noticable when kinematic puppet is on the ground.



    Can you give me advice on how I can fix it?
    Thanks!
     
    Last edited: Feb 15, 2019
  19. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    731
    It was with a Samsung Galaxy S8+, but I made a trigger system so that PuppetMaster only becomes active on the pedestrians when they come into range of something they can collide with (an object I throw at them, a vehicle, etc) and then once they finish everything and go back to normal state, if nothing is around or happening to trigger unpinning they go back to PM disabled so that they are not all calculating constantly.
     
    Subliminum likes this.
  20. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,908
    Hey,
    That is a bug, thanks for reporting! You can fix it by going to BehaviourPuppet.cs, in protected override void OnReadBehaviour() there is a segment like this (should be around line 740, depending on your version)
    Code (CSharp):
    1. if (!puppetMaster.isFrozen) {
    2.                 if (state == State.Unpinned && puppetMaster.isActive) {
    Please change it to this:
    Code (CSharp):
    1. if (!puppetMaster.isFrozen) {
    2.                 if (state == State.Unpinned && puppetMaster.isActive && !puppetMaster.isBlending) {
    Hey, thanks for the additional info!
    Cheers,
    Pärtel
     
    Subliminum and JacobDzwinel like this.
  21. farzaan090

    farzaan090

    Joined:
    Jul 23, 2018
    Posts:
    15
    Is there a way to only have certain Groups (i.e. the Prop group) collide with a certain layer?

    Even though I am using the unmapped mode, I don't want collisions that don't unpin the puppet to occur between the Legs/Head/Hips of my puppet with another x layer but I do want collisions from the prop group to collide with this x layer.

    Basically, I only want the prop group (the weapon) to collide with an object on x layer but not the other Groups in my Puppet to collide with an object on x layer.



    Question 2: Are there any best practices for when scaling the root of your puppetmaster up? I've noticed the props in particular can act very wonky when you do so.
     
    Last edited: Feb 23, 2019
  22. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    469
    Hi, Partel, PuppetMaster is a really interesting product and I'm having lots of fun just watching it.
    However, there is one problem with the ragdoll colliding with the ground when walking/running and it makes the character jittery.
    The problem is obvious because the feet is colliding with the ground when moving.

    I guess I can get around by making ground layer not to collide with the feet but then I'll still have a problem when a character is standing on any non-ground object.

    I think the correct solution is to disable feet collision when on standing and enable the collision when losing balance.
    I'm sure this is a common problem and please let me know what the right solution is.

    Thanks.
     
    mbartosik likes this.
  23. NewMagic-Studio

    NewMagic-Studio

    Joined:
    Feb 25, 2015
    Posts:
    62
    I am using VRIK and when i hit an object with puppetmaster with a behaviour so that i falls to ground it goes to ground even with very soft hits, i would like it goes to ground just with strong hits and just if i hit it a lot of times or randomly
    Also would like to use VRIK with puppetmaster
    Also when i go near the model with puppetmaster it is pushed away very far and very fast, it tried reducing the Max rigidbody velocity in the Behaviour puppet but didnt change anything
     
    Last edited: Feb 27, 2019
  24. duckburger

    duckburger

    Joined:
    Dec 7, 2016
    Posts:
    5
    Hello,

    Awesome asset, and I am having fun tinkering with it.

    I am trying to fling a character across the screen with a force applied to each limb's Rigidbody.

    The character starts in Kinematic mode, with blend time set to 0, and my launch code looks like this:

    Code (CSharp):
    1. private void LaunchMainPassenger()
    2.     {
    3.         ragdollController.Kill();
    4.         localLaunchDirection = this.transform.TransformDirection(launchDirection);
    5.         foreach (Muscle m in ragdollController.muscles)
    6.         {
    7.             m.rigidbody.AddForce(localLaunchDirection * launchSpeed, ForceMode.Impulse);
    8.         }
    9.         carController.speed = 0; // The character is in a car, so that's why I am stopping the car in place here
    10.         carRB.velocity = Vector3.zero;      
    11.         CameraManager.Instance?.SwitchToLaunchCam(ragdollController.transform.GetChild(0));
    12.         Debug.Log($"Added velocity to rigidbody {ragdollController.muscles[0].rigidbody.gameObject.name}");
    13.     }
    I want the character to also to be able to return to its exact position before it was launched. Here is what my reset code looks like:

    Code (CSharp):
    1. if (Input.GetKeyDown(KeyCode.R))
    2.         {
    3.             ragdollController.mode = PuppetMaster.Mode.Kinematic;
    4.             ragdollController.Resurrect();          
    5.             ResetMainPassenger(); // Resets the position of each limb on the character to the original position
    6.             hasLaunched = false;
    7.         }
    The result of these two behaviours is that when I first call the launch function, the character simply falls over in place. When I launch him a second time the force does end up being applied. It seems to have something to do with how quickly PuppetMaster is able to switch modes?

    When I reset the character to the original position he falls flat on his face then takes a second to stand up or sometimes just continues to fly forward with the force still being applied.

    The 2 behaviours I have attached to the puppet are Fall and Puppet (with Fall).

    Am I missing something here? Is there a better way to apply a burst of force to a character, let him fly in ragdoll, collide with stuff and then reset him to the exact position/state he was in before the launch?

    Appreciate the help!
     
  25. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,908
    Hey,
    With the next version of PuppetMaster, you can define per muscle, which muscle groups they collide with, so if you are in a hurry, please PM me with your invoice number and I'll send you the latest. There's also a new much faster and more efficient prop system, as the current implementation is very slow and allocating to GC.

    About the scaling, there is a "Scaling" demo included. Basically you'll have to keep in mind that when you change the scale of a Rigidbody with a collider, Unity recalculates Rigidbody.inertiaTensor and that is done based on collider size and shape. So larger colliders have a larger tensor, which makes them heavier to rotate, which is probably the wonkiness you noticed. You'll have to increase puppetMaster.muscleSpring exponentially by the scale value:

    Code (CSharp):
    1. puppetMaster.muscleSpring = defaultMuscleSpring * Mathf.Pow(masterScale, 2f);
    Hey,
    Yes, if you go to the "Group Overrides" under the "Muscle Group Properties" in BehaviourPuppet, you should have a group override for the Foot group (can add one if you don't). Expand that, you can enable "Disable Colliders" there, which disables the foot colliders while the puppet is pinned and enables them while not.

    Could also set up the feet with a PhysicMaterial that has 0 friction (use the "Puppet Material" and "Unpinned Material" in group overrides again) and if you have Final IK, add the Grounder for foot placement correction to avoid pushing the feet through the ground on bumpy terrain and stairs.

    Hey,
    Here's a demo with VRIK-PuppetMaster setup. Requires Oculus/SteamVR utilities.
    But about your question, did you try increasing the Collision Resistance value in BehaviourPuppet?
    I'm not sure about the second problem about max velocity. could you please make a video or something so I could better understand what might be going on there?

    Hey,
    When a puppet exits the Kinematic mode, PuppetMaster will set the velocities of muscles to muscle.mappedVelocity to maintain the animated velocity, so that overrides your AddForce commands. Instead of using AddForce, just apply the force directly to muscle.mappedVelocity:

    Code (CSharp):
    1. foreach (Muscle m in puppetMater.muscles) {
    2. m.mappedVelocity += (localLaunchDirection * launchSpeed) / m.rigidbody.mass;
    3. }
    About the resetting, please try the approach in "Puppet Respawning" demo, using PuppetMaster.Teleport(); There might be minor glitches with that under certain conditions in the current version, but that has been fixed for the next version.

    Best,
    Pärtel
     
  26. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    469
    Hi, Partel, I tried a quick test on "Puppet Extended" Scene but it doesn't seem to work as I expect.
    I first set the Ground layer to "default" and tried to disable Foot collision and also tried to use Zero-friction physics material but it still trips over.

    And one other problem is that once the puppet falls, it cannot get up again.

    Having PM to work any surface is important so that I can enable PM all the time.
    I appreciate if you can help.

    Thanks.
     
  27. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,908
    Hey,
    Make sure the ground layer is not included in BehaviourPuppet's "Collision Layers". If it was, the collisions between the ground and the puppet body parts would keep damaging the puppet, especially when getting up when many body parts touch the ground, it would not let it get up properly.

    About the foot collisions still happening, when you pause the game while in normal puppet state and select the feet, are the colliders on them enabled? Do you have muscle groups set up in PuppetMaster, I mean when you expand the Muscles on the bottom of PuppetMaster, do you see the foot muscles having "Foot" for Group?
     
  28. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    469
    Hm.. I'm not really sure if I explaining it correctly.
    Let's say you are on a building and trying to get up, does that mean I have to exclude the building layer from the Collision Layer? I'll then have to remove most of the objects from the collision layer.
    This will severly limit PM usage as it cannot interact.


    Yes, the foot group is set up and the collision disabled correcly. I'm doing this on PM "Puppet Extended" scene. Here is the Foot group setup. Thanks.
    upload_2019-2-27_22-14-40.png
     
  29. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    469
    With some experient and tweaking, I think I got it to behave the way I want, almost...
    I think I need to play with it a bit more to get the feel I want.

    In the meantime, here is a new problem.
    When I get close to ragdoll collidable object, for example, a wall, and jump right next to the wall, the character will be thrown like a rocket launch. ^^

    I think what happens is that the foot (collision was turned off by behavior) has penetrated the wall right before the jump and the jump(hand action) throws the balance thus it goes into the unbalanced mode. The foot was already penetrated and the collision got turned on while penetrated. Any idea how to fight this?

    I guess there are two problems, rocket launch problem and hard to get up problem(The default Mussle Weight and Pin Weght is set to 1)

    Update: Jumping right next to a wall (Green wall) in the default PuppetExtended Scene will do the rocket launch.
     
    Last edited: Feb 27, 2019
  30. Soulghai

    Soulghai

    Joined:
    Mar 24, 2016
    Posts:
    14
    Hello!
    I have a little issue here =)

    Puppet ragdoll and capsule collider (character Controller) have different positions after lose balance.
    Any ideas =)? Thank you
     
    Last edited: Feb 27, 2019
  31. duckburger

    duckburger

    Joined:
    Dec 7, 2016
    Posts:
    5
    Hello again, Pärtel,

    Your advice totally helped and the puppet now resets to its correct position with its velocity set to zero. However the last piece of the puzzle still stands: if I change the puppet's mode back to Kinematic in Teleport(), it has no bearing on the puppet. Is there an instant way to switch to Kinematic mode?

    Thank you.
     
  32. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,908
    Hey,
    It would be best to have walkable surface colliders on the ground layer, like the walls of the building on collision layers, but the floors and the roof on ground layer. I understand it is more difficult If your building is a signle mesh collider. Other than that, one way to separate the floor from the walls would be to compare the contact normal to Vector3.up. So you could try adding this line to BehaviourPuppetDamage.cs, line 41:
    Code (CSharp):
    1. if (Vector3.Dot(m.collision.contacts[0].normal, Vector3.up) > 0.7f) return;
    Use m.collision.GetContact(0) if you're on Unity 2018.3 or later to avoid memory allocation.
    That line would make BehaviourPuppet skip processing collisions with near vertical normals.

    Hey,
    The problems comes from the unrealistic acceleration of typical game character jumping. When real people jump, the acceleration of the center of mass is actually very smooth and the trajectory looks like a sine curve:
    Jump.JPG
    But when game characters jump, it is usually done by a single AddForce impulse, which accelerates the character to jump velocity in an instance. Then PuppetMaster will have to apply tremendous pinning forces to make the ragdoll catch up with that acceleration. If the puppet gets unpinned at that time, there will be no pinning forces to decelerate the ragdoll and it will continue flying up with that force. So to fix that problem, I can think of a couple of ways:

    1. Apply jump acceleration smoothly over a number of fixed time steps (perhaps a coroutine with yield WaitForFixedUpdate), not just AddForce from a single FixedUpdate.
    2. Increase the character capsule temporarily when jump starts to prevent it from depinning.
    3. Set behaviourPuppet.knockOutDistance to Mathf.Infinity temporarily when jump starts.

    Hey, which Transform do you have assigned as "Target Root" in PuppetMaster? Is it the transform of the capsule's Rigidbody or something else?

    Hey,
    What do you have for "Blend Time" in PuppetMaster? If its greater than 0, it will take that time to blend to Kinematic mode.

    Best,
    Pärtel
     
  33. Soulghai

    Soulghai

    Joined:
    Mar 24, 2016
    Posts:
    14
    I used AnimatorController (as in your examples).
    But then I changed it to GameObject with player CapsuleCollider and all work well!

    Thanks a lot! You did a great job!
     
  34. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    469
    Hi, Partel,
    The following check is an interesting idea. It will automatically assume that anything near vertical( stuff that player can stand-on) treated at Ground.
    However, when I inserted the line, the character will fall through the ground. I guess finding where to check is tricky and I'll appreciate if you can help. Perhaps you should make this into the core as it is general problem for everyone.

    Code (CSharp):
    1.     if (Vector3.Dot(m.collision.contacts[0].normal, Vector3.up) > 0.7f) return;
    2.  
    Sure, I understand about jumping. I think the problem is that while jumping, there is briefly a moment where character collision has penetrated the wall and the physics code try to push it away.
    I think 3 suggestion may have some problems though.

    1. Jump must be immediate but it will make the character quite sluggish.
    2. Just making the capsule collier bigger may have the same problem pushing the character away from the wall suddenly.
    3. Turning the knockout distance temporarily doesn't guarantee that the character is not penetrating when it's back to normal.

    I think we should prevent the ragdoll to penetrate the object in the first place.

    The rocket launch problem happens on the default "Puppet Extended" scene you included in the PM.
    Perhaps you can try it on the scene and let us know what would be the official solution is. Try to jump right next to Green wall or Blue object and you will see the rocket launch. But of course, this won't happen near the Black wall.
    upload_2019-2-28_22-56-31.png
     
    Subliminum likes this.
  35. NewMagic-Studio

    NewMagic-Studio

    Joined:
    Feb 25, 2015
    Posts:
    62
    I tried your VRIK Puppetmaster demo and tried it in my project but there is a problem which is that the item i hold in my hand when i push it over a wall it bends the object more than the hand is bent so it goes through the hand.
    Also i tried pushing some times on the wall and once the arm started rotating around like crazy, i would need something stable, is that possible?

    The problem i had with puppetmaster is that when my player goes near the enemy the enemy flies away many metres
     
  36. duckburger

    duckburger

    Joined:
    Dec 7, 2016
    Posts:
    5
    I have it set to 0.

    Here is the behaviour I am getting in the editor + my code I am using to produce the behaviour. The SetVelocitiesForMuscles simply sets all muscles' mapped velocities to 0 as you suggested. Thank you for sticking with me through this problem!



    Code: https://pasteboard.co/I3l26bj.png
     
  37. Subliminum

    Subliminum

    Joined:
    Nov 9, 2017
    Posts:
    71
    I've had issues with this 'rocket jump' behaviour also and have not gotten around to figuring out how to fix it. It would be great to see this issue resolved in an update!
     
  38. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,908
    Hey,
    I see the problem in Puppet Extended. I'll try to figure out a solution asap, thanks for reporting the issue!

    Hey,
    Any chance you could send me a repro via PM? Because I'm not seeing anything like that in those demo scenes. Or please let me know steps I can take to reproduce.
    About that flying away issue, does it happen on contact or just from being near? Maybe the ragdoll layer collides with the enemy character controller so the ragdoll pushes the enemy capsule?

    Something I noticed in that video, you have all the IK and Grounder stuff on the PuppetMaster hierarchy, which is wrong and might produce all kinds of trouble. All the IK stuff should be on the other hierarchy, the one with the Animator. PuppetMaster hierarchy is supposed to be controlled by physics only.

    Hey,
    Hold on please, working on it...

    Cheers,
    Pärtel
     
    Subliminum likes this.
  39. duckburger

    duckburger

    Joined:
    Dec 7, 2016
    Posts:
    5
    Oh, I was wondering about that. Thanks for pointing it out! I will move it and try again.
     
  40. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,528
    I would like to rig a non biped/quadruped. Specifically the Mech Spider from the Final IK demo.

    The legs have more than three segments. Can PuppetMaster work with this?
    Also there are more than four legs, no spine, chest, head & legs all connect to the hips.
    The Mech is procedural animated (no Animator component).

    Any tips?
     
    Last edited: Mar 3, 2019
  41. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,908
    Hey,
    PuppetMaster can work with any rig, but BehaviourPuppet was designed for bipeds only (probably still works with most characters though). BipedRagdollCreator can only do bipeds though, so you'd need to set up the ragdoll manually. PuppetMaster requires ConfigurableJoints, but you can set it up with Character or Hinge Joints, if it's more intuitive, then select the root of the ragdoll and do GameObject/Convert To ConfigurableJoints. You can still use RagdollEditor to tweak the colliders and joint limits.

    Best,
    Pärtel
     
    Subliminum and Phong like this.
  42. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,528
    First Attempt looks promsing: https://twitter.com/DigitalOpus/status/1102987704109694976
     
    Partel-Lang and Subliminum like this.
  43. ncho

    ncho

    Joined:
    Feb 1, 2014
    Posts:
    78
    Just wondering if there's any news on the integration with the Opsive controller assets yet as that's the only thing holding me off from buying this.
     
  44. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,908
    Hey,
    I'll try to get to it next week, currently in the middle of a major update to the prop and muscle cutting system and fixing the puppet jumping to space bug...

    Best,
    Pärtel
     
    Subliminum likes this.
  45. ncho

    ncho

    Joined:
    Feb 1, 2014
    Posts:
    78
    Sounds great, looking forward to it.
     
  46. Epiplon

    Epiplon

    Joined:
    Jun 17, 2013
    Posts:
    26
    Hello Partel, thanks for the awesome tool.

    I'm using it regularly and have some request: can you make the methods in the
    IKSolverLookAt
    class as protected, as well as other important parts of the code?

    I want to made few modifications but they are all
    private
    .

    Thanks!
     
  47. NewMagic-Studio

    NewMagic-Studio

    Joined:
    Feb 25, 2015
    Posts:
    62
    I got to solve other issues but my player uses navmeshagent and when i teleport i see my body goes back to player camera after a second but not at the same time, i teleport with VRIK and a bit later appears the body moving to that position but i want it happens inmediately. That already happened before using puppetmaster but also i realize when i teleport to other place where there is part of a column in the way the body appears displaced and rotating the head in a weird way. So what i want is just to teleport and with navmeshagent move the camera, the vrik and puppetmaster bodies at the same time and without having problems if there is something in their way like a column. I see there is a teleport script in your vrik puppetmaster scene but it doesnt work in my case, it doesnt even trigger the OnPuppetMasterRead method, i tried calling the solver.Reset method for Vrik after teleporting but doesnt help
     
  48. duncanpcarroll

    duncanpcarroll

    Joined:
    Mar 11, 2019
    Posts:
    1
    Hey Partel,

    Is it possible to use a joint to attach a hand muscle to another rigidbody? I've only been able to successfully attach the hips muscle without the rest of the ragdoll freaking out.
     
  49. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,908
    Hey,
    Why not, I'll change them to protected so you won't have to redo when you update.

    Hey,
    I have revised the teleporting script so it accounts for the physical offset of the player from the tracking space, which might be the glitch you were seeing. Here's the code:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using RootMotion.FinalIK;
    4. using RootMotion.Dynamics;
    5.  
    6. public class TeleportVRIKPuppet : MonoBehaviour {
    7.  
    8.     public Transform target;
    9.     public Transform cameraRig;
    10.     public PuppetMaster puppetMaster;
    11.     public VRIK ik;
    12.  
    13.     private bool teleportFlag = false;
    14.     private float cameraRigHeight;
    15.  
    16.     /// <summary>
    17.     /// Teleport this VRIK Puppet to the target position and rotation.
    18.     /// </summary>
    19.     public void Teleport()
    20.     {
    21.         // PuppetMaster.Teleport() is not processed immediately, but with the next PuppetMaster.Read(), so we need to move the camera rig when that happens.
    22.         teleportFlag = true;
    23.  
    24.         puppetMaster.Teleport(target.position, target.rotation, true);
    25.     }
    26.  
    27.     private void Start()
    28.     {
    29.         if (target == null) Debug.LogError("'Target' unassigned in TeleportVRIKPuppet", transform);
    30.         if (cameraRig == null) Debug.LogError("'Camera Rig' unassigned in TeleportVRIKPuppet", transform);
    31.         if (puppetMaster == null) Debug.LogError("'Puppet Master' unassigned in TeleportVRIKPuppet", transform);
    32.         if (ik == null) Debug.LogError("'IK' unassigned in TeleportVRIKPuppet", transform);
    33.  
    34.         // Get the height of the camera rig from the ground
    35.         cameraRigHeight = cameraRig.position.y - puppetMaster.targetRoot.position.y;
    36.  
    37.         // Register to get a call from PuppetMaster when it reads
    38.         puppetMaster.OnRead += OnPuppetMasterRead;
    39.     }
    40.  
    41.     // Called by PuppetMaster when it reads
    42.     void OnPuppetMasterRead()
    43.     {
    44.         if (teleportFlag)
    45.         {
    46.             // Rotate the camera rig to the target
    47.             Quaternion rotationDelta = RootMotion.QuaTools.FromToRotation(cameraRig.rotation, target.rotation);
    48.             cameraRig.rotation = rotationDelta * cameraRig.rotation;
    49.  
    50.             // Move the camera rig to the target
    51.             Vector3 positionDelta = (target.position - ik.solver.spine.headTarget.position);
    52.             positionDelta.y = (target.position.y + cameraRigHeight) - cameraRig.position.y;
    53.             cameraRig.position += positionDelta;
    54.            
    55.             // Reset the solver for locomotion
    56.             ik.solver.Reset();
    57.             teleportFlag = false;
    58.         }
    59.     }
    60. }
    61.  
    Just call TeleportVRIKPuppet.Teleport();
    It is not possible to teleport a puppet immediatelly though, PuppetMaster is basically like a state machine, it has to be because of the internal update order of animation and physics in Unity. So if you call PuppetMaster.Teleport(), it will be processed the next time PuppetMaster reads, which is the next FixedUpdate if you are in AnimatePhysics Animator update mode or LateUpdate if Normal mode.

    Anyway, I don't see any glitches with this code in the demo anymore. I wonder why you are not getting OnPuppetMasterRead(), it is always called by PuppetMaster if you have registered to it and PuppetMaster is not disabled.

    Hey,
    Yes, but you'll have to reduce or zero out the pin weights for the arm, to allow the hand to reach it. Otherwise that joint and the forces pinning the arm to the animation would start fighting each other and that's what is freaking out the ragdoll.

    Best,
    Pärtel
     
  50. Noah_Zuo

    Noah_Zuo

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

    I am currently using puppetmaster for our game character. It works fine but there stills a small issue when we use this plugin.

    When we try to reduce the Muscle Weight to 0(without setting Pin Weight to 0), the character limbs just oriented to a strange direction.

    How should I solve that problem please? What does Muscle Weight exactly mean?
     
    Last edited: Mar 15, 2019