Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

PuppetMaster - Advanced Character Physics Tool [RELEASED]

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

  1. JacobDzwinel

    JacobDzwinel

    Joined:
    Dec 19, 2013
    Posts:
    17
    Hi Partel!

    Since I'm working on optimization in my game I'm curious if it's possible to have my PuppetMaster and BehaviourPuppet deactivated when I want, and use it only when my character is unpinned or in getup state? I still need to have my Puppet muscles in kinematic mode and send hit collision messages but I see that there are a lot of background calculations that I don't need in my game because when my character get hit, I clear all velocities, switch my Puppet from Kinematic to Active, unpin it and give force manually (just to have better control of ragdoll forces). Everything works great, but I would like to get rid off other unnecessarily calculations while my characters aren't in unpin/getup mode.

    Do you think it's possible?

    Also can you help me how I can achieve "Domino effect" when I kick enemy and I want him to knock over other characters standing behind him with lower velocity change on contacts. When I'm increasing the mass, my character ragdoll behave really strange.

    Thanks!
     
    Last edited: Aug 26, 2019
  2. flow-

    flow-

    Joined:
    Apr 19, 2015
    Posts:
    143

    Thank you, it just works!

    I got problems with the Animation which was not always in the forward direction so I extended the method a little to this:
    Code (csharp):
    1.  
    2.     public static void RotatePuppetMasterRagdoll(PuppetMaster puppetMaster, Quaternion wantedRotation, Vector3 rotationOffsetEuler, float lerpSpeed ) {
    3.             var angle = 0f;
    4.             var angleAxis = Vector3.up;
    5.             var pelvis = puppetMaster.muscles[ 0 ];
    6.             var wantedEuler = wantedRotation.eulerAngles;
    7.             var baseRotationEuler = Quaternion.Euler( rotationOffsetEuler.x, pelvis.joint.transform.rotation.eulerAngles.y + rotationOffsetEuler.y, rotationOffsetEuler.z ).eulerAngles;
    8.             var differences = Quaternion.Euler(wantedEuler - baseRotationEuler);
    9.             differences.ToAngleAxis( out angle, out angleAxis );
    10.             Vector3 pelvisPos = pelvis.joint.transform.position;
    11.             puppetMaster.transform.rotation = Quaternion.Lerp( puppetMaster.transform.rotation, Quaternion.AngleAxis( angle, angleAxis ) * puppetMaster.transform.rotation, lerpSpeed * Time.deltaTime );
    12.             puppetMaster.transform.position += pelvisPos - pelvis.joint.transform.position;
    13.         }
    14.  
    With this it's getting the the rotation of the Hips instead of the PM root, it made my puppet more stable even with Animations who are rotating the puppet.
    I hope someone needs this as I did...
     
  3. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    880
    I have been waiting for this since UCC came out unfortunately. My game heavily relies on PM, so I have been stuck using TPC v1 still. All the rest of the integrations I would need have came out so far minus PM, so fingers crossed it comes soon. : D
     
  4. Deckard_89

    Deckard_89

    Joined:
    Feb 4, 2016
    Posts:
    205
    Unfortunately both asset developers are having a hard time getting PM working with UCC.
     
  5. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    880
    They are both top tier devs. I maintain faith in their abilities. : D
     
    Last edited: Aug 20, 2019
    Deckard_89 likes this.
  6. wojwen

    wojwen

    Joined:
    Feb 13, 2018
    Posts:
    19
    Hi Partel!

    I'm doing some prototyping for my next project and I'm trying to combine VRIK with PuppetMaster, but I'm having some issues. Maybe you could tell me what I'm doing wrong or at least why does it work like this?

    First, I've set up a simple VRIK character, here is a GIF of me calibrating and testing it, you can see that the hands match up perfectly with my controllers:



    After that I've set up PM to follow the IK-driven character, here is how it looks in the hierarchy:

    Unity_KXSlxKPGKv.png

    And here is how it works, the visible skinned mesh is based on the PM puppet:



    The problem is that it doesn't follow the pose exactly, you can see that the hands are always a bit off, while previously (with VRIK) they were spot on. How much they are off changes based on their rotation and position. I know that this is a physics simulation, but I know PM can be very precise based on how it's following animations.

    One thing I don't understand is that the PM seems to be affecting the IK-driven character. If I keep the PM enabled, but switch its skinned mesh renderer off and turn the skinned mesh renderer for the VRIK character on it behaves exactly the same as the PM mesh renderer (the hand position is off, compared to pure VRIK), while previously (in the first GIF) it was perfectly aligned:



    This makes me think that PM is somehow affecting VRIK, but I thought that it should solve after VRIK.
    Could you help me with setting this up properly?

    EDIT: I'm using Unity 2019.2.1

    Thanks!
     
    Last edited: Aug 26, 2019
  7. flow-

    flow-

    Joined:
    Apr 19, 2015
    Posts:
    143
    Hey, I get an error while I Generate my UMA Animal and set up puppet master on it.

    2019-08-27 16_19_09.png

    I really can't change the Secondary Axis because it's generated by puppet master itself at runtime, do I need to change the Rig of the Animal?
     
  8. NewMagic-Studio

    NewMagic-Studio

    Joined:
    Feb 25, 2015
    Posts:
    67
    Arms sometimes move very fast randomly at start, i am using vrik and puppetmaster, usually doesnt happen but sometimes yes, i already sent you an email but seems you dont see emails anymore
     
  9. krehzzzy

    krehzzzy

    Joined:
    Dec 31, 2015
    Posts:
    7
    Hello! Have you had a chance to try thew new joint solver in 2019.3? Supposed to help quite a bit with ragdoll/joint stability and performance. Wonder if it will cause any bugs with PM/FIK
     
    corjn likes this.
  10. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    880
    Those waiting, if you look for partels last post, he said he will be unavailable until the 30th.
     
    wojwen and hopeful like this.
  11. corjn

    corjn

    Joined:
    Feb 6, 2014
    Posts:
    87
    Hey, I tried it ! It's amazing of stability, with temporal gauss siedel, long chains are not breaking anymore at all whith high velocity. But i'm getting the editor to crash with puppetmaster's tests scenes every minutes or so, making it very unstable for now. But it's 2019.0b1 so I'm sure it will be fixed until the 0f1.

    Edit :
    Also have crashes on empty scenes. Made a build of the "melee" demo and it's not crashing at all. So it's very probably just 0b1 being unstable.
     
    Last edited: Aug 31, 2019
    wojwen likes this.
  12. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,965
    Hey,
    In Kinematic mode there is still work to be done by PM to move the ragdoll colliders to match the animation, but that's mostly it. You could try switching to Disabled mode instead, then have a large trigger collider on the character that checks for any incoming projectiles or enemies and switches to Active when it finds any.

    About the domino effect, you could try using the Boosters. define a public Booster booster; in your AI script so you could fill it in in the editor. If a puppet gets kicked, call booster.Boost(behaviourPuppet); to give it a "boost" of damage it applies to other puppets and/or immunity. In the booster, there is "impulseMlp", if you set it to 10, other puppets receive 10x damage from collisions with that puppet. The boosting effect falls off over time, defined by "Boost Falloff" in BehaviourPuppet. Value of 1 means the effect will be over in 1 second.

    Hey,
    It has proven to be much more difficult than I thought, mostly because of the new way UCC updates the animator, which is different from the Normal/AnimatePhsyics modes in Unity. I'm currently working hard to update to the next version of PM, after that I can pick it up again.

    Hey,
    The inaccuracies could be due to either joint limits or internal collisions not allowing for enough freedom for the ragdoll to follow the animation. So please try disabling "Angular Limits" and "Internal Collisions" in PuppetMaster to see if that is the case.

    PM affects the IK-driven character because both skinned mesh renderers follow the same bone hierarchy that is controlled by PM when it is enabled. To disable the visual effect PM has on the character, set "Mapping Weight" to 0. The physics will still work, but the animated rig will not be mapped to the physical rig.

    Hey,
    BipedRagdollCreator was not designed to be used on animals. But if it still works somehow and if that error is the only thing keeping you from using it, you can probably add in a line of code to change joint.secondaryAxis of the "Joint Calf_L" ConfigurableJoint before you call puppetMaster.SetUp(); That error is produced when PM finds joint.secondaryAxis == joint.axis.

    Hey,
    Just replied to your email.

    Hey,
    Yeah, I tried it.. Didn't notice much difference with the "Melee" demo, but you can notice it in the "Hanging" demo if you move the target fast. With the old solver it breaks apart easily, with the new one it doesn't. It's a general ragdoll stability problem unrelated to PM really, but I'd recommend you to use the new solver only when you see problems with the ragdolls breaking up under joint stress, just because the old solver is faster. Didn't see any crashes though.

    Cheers,
    Pärtel
     
    flow-, wojwen and corjn like this.
  13. wojwen

    wojwen

    Joined:
    Feb 13, 2018
    Posts:
    19
    Hey,

    Thanks for the reply! I managed to figure it out today. The Angular Limits and Internal Collisions have already been disabled, but the thing I was doing wrong was the scaling itself. When I changed the VRIK puppet scale using the VRIKCallibrationController the PM ragdoll changed its scale on its own (I didn't have any additional scripts for that). I assumed that it did it correctly, but turns out I had to use the PuppetScaling script on the ragdoll as well.

    While I have your attention, the next thing I will be solving is a two handed weapon. Is there a proper way to do it with PM and VRIK? Is it better to do the pose adjustment (assuming that the hand trackers aren't exactly on the weapon handle) in VRIK or to just "force it" with joints and PM? Or is there a better way to do this?

    Thanks!
     
  14. PlayingKarrde

    PlayingKarrde

    Joined:
    Aug 19, 2013
    Posts:
    28
    I'm considering moving away from Mecanim to a different animator system (specifically Animancer). However I think Puppetmaster relies on the Mecanim controller is that correct? Certainly the behaviors are looking for the animation clips and blend trees in the controller.

    Is there any way I can decouple these so that I can use a different animation method or am I stuck with Mecanim if I want to use Puppetmaster and behaviors?
     
    Last edited: Sep 2, 2019
  15. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,965
    You will be going to uncharted territory with that, I haven't tried PM with VRIK for 2-handed weapons myself. I doubt you will get satisfying accuracy with just the joints alone, PhysX is not that accurate nor stable. It is possible to apply cosmetic IK on top of PM to fix any minor inaccuracies though if you have Final IK. In Plugins/RootMotion/PuppetMaster/_Integration there is the Final IK integration package and that has the "IK After Physics (Final IK)" and "Ragdoll Aiming" demo that shows you how you can use PuppetMaster.OnWrite delegate to apply some IK on the final pose. The "Ragdoll Aiming" demo especially, because it has a 2-handed prop example.

    Hey,
    PuppetMaster also works with Legacy animation, so you don't necessarily need Mecanim. The behaviours are looking for animation states by default, but you can also clear the animations from the "On Lose Balance" and "On Get Up Prone/Supine" events and use the Unity Events to call any method that employs your custom animation solution.

    Best,
    Pärtel
     
  16. PlayingKarrde

    PlayingKarrde

    Joined:
    Aug 19, 2013
    Posts:
    28
    Oh perfect, yes UnityEvents would make perfect sense here. Thanks!
     
  17. PlayingKarrde

    PlayingKarrde

    Joined:
    Aug 19, 2013
    Posts:
    28
    I have another question that I'm a little confused about. You mentioned in the documentation that if you want two enemy types (let's just say two opposing players) they need to be on different layers (and the same for ragdolls). This doesn't feel very scalable to me since, what if I want, say, 8 players. Do I need to create layers for each of them? What if it's 64 players?

    Am I thinking about this in the right way? It's possible I'm getting my wires crossed somewhere.

    -edit- Just to tack onto this question one more; how important is it to have the update set to Update Physics? The third party animation system I am using (Animancer) doesn't appear to be working when I set it to Animate Physics and I can't work out why. The author is unsure why too and doesn't believe the issue is on his end. If it's important to have Update Physics on the animator (as I suspect it likely is) do you have any ideas why my character would be stuck in it's reference pose when this is set? It is definitely some combination of Animancer and Puppetmaster with Update Physics as it works fine without Puppetmaster enabled, or with the update mode set to Normal.
     
    Last edited: Sep 5, 2019
  18. alexkarak

    alexkarak

    Joined:
    Feb 7, 2018
    Posts:
    7
    Hey parel i have a grenade script but i cant figure out how to apply explosion force to all my puppets...i read an answer you gave about it in a previous question but i cant find how to acces the puppet master script from the grenade script

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class Grenade : MonoBehaviour
    {
    public float delay = 3f;
    public GameObject explosionEffect;
    public float blastRadius = 5f;
    public float force = 200f;

    float countdown;
    bool hasExploded = false;


    // Start is called before the first frame update
    void Start()
    {
    countdown = delay;
    }

    // Update is called once per frame
    void Update()
    {
    countdown -= Time.deltaTime;
    if (countdown <= 0f && !hasExploded)
    {
    Explode();
    hasExploded = true;
    }
    }
    void Explode()
    {
    Instantiate(explosionEffect, transform.position, transform.rotation);
    Collider[] colliders = Physics.OverlapSphere(transform.position, blastRadius);
    foreach (Collider nearbyObject in colliders)
    {
    Rigidbody rb = nearbyObject.GetComponent<Rigidbody>();
    if (rb != null)
    {
    rb.AddExplosionForce(force, transform.position, blastRadius);
    }

    }

    Debug.Log("Boom");
    Destroy(gameObject);
    }
    }



    This is my script but i cant find how to write it down so it can take a reference from puppetmaster script to add force to the muscles ...i have tried so many things and still cant figure it out (i am a noobie at scripting so sorry if it is too obvious) :/
     
    Last edited: Sep 4, 2019
  19. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,965
    Hey,
    You don't need to have different layers for each player, just each faction. Like one layer set for the player and another for all the enemies no matter the number. If it is a multiplayer game where all players are equal, you can do with just one layer set.

    It is not important to use AnimatePhysics. Actually I'd prefer if you used Normal. AnimatePhsyics doesn't make much sense with active PuppetMaster, the ragdoll is controlled by physical forces anyway so it already applies friction and proper collision to objects in the scene.

    Hey,
    You can get a reference to PM if you find a MuscleCollisionBroadcaster from a Rigidbody.

    Code (CSharp):
    1. var b = rb.GetComponent<MuscleCollisionBroadcaster>();
    2.  
    3. if (b != null) {
    4. var puppet = b.puppetMaster.behaviours[0] as BehaviourPuppet;
    5. puppet.SetState(BehaviourPuppet.State.Unpinned); // Unpin the puppet, otherwise AddExplosionForce will have no real effect.
    6. }
    7. rb.AddExplosionForce(...);
    8.  
    9. }
    Best,
    Pärtel
     
  20. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,965
    Hi all!

    So finally I have managed to push the next versions of both Final IK and PuppetMaster! :)

    What kept it so long was mostly the new high speed prop API of PuppetMaster and the new Baker feature added to both FIK and PM.

    I have also done a complete revision and update of the documentation and added in all the missing pages for VRIK, ArmIK, LegIK and others. Check it out here.

    Please take a moment to check out the new Baker tool:




    As ever, with new versions there might be some unexpected bugs so please let me know as soon as you find any.

    Cheers,
    Pärtel
     
  21. PlayingKarrde

    PlayingKarrde

    Joined:
    Aug 19, 2013
    Posts:
    28
    But in my case each player is opposing one another, so would they not be considered different factions using your terminology? I want each player to be able to damage the others so in this scenario do I need to create layers for each?

    Also, related when I do this my character controller tries to walk up the other and it's quite strange behavior. At first I thought it might be because of the step up settings (and it still might, I haven't looked into it much) but also when attacking, say using a punch, both players kind of glitch into the air a bit rather than the expected hit reaction to the punch.

    Along these same lines, do you recommend a rigidbody type approach to a character controller over a standard one? I went with a character controller at first just because it was faster for me to get up and running, but if you recommend a rigidbody (and I do want physics to be affecting as much as possible in my game, but still with tight control) I will take the time to convert it over.

    Thanks for the reply and the new baker work looks great!
     
  22. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,965
    Hey,
    If all your players are equal, then go with 1 layer set. What I meant with factions was when you need different settings for each faction, like having a super strong player and a bunch of NPCs that you can more or less run over.
    The only reason you would need another layer set for is the ability to use stuff like Collision Resistance Multipliers of BehaviourPuppet to make the player puppet more resistant to collisions from the NPC ragdoll layer. Or in another case use different layer sets for example make puppets of the same faction ignore collisions with each other, but not the enemies.

    About the character controller issue, would it be possible for you to record a video of it?
    Also please try setting PuppetMaster mapping weight to 0 to see if the issue is related to PM at all.

    I normally use a custom scripted Rigidbody because CharacterController is a sealed Unity component and you will probably run into a brick wall with it sooner or later so better replace it early.
    I have lately started to use a suspended rigidbody, basically a floating capsule. That is done by making a raycast down from the center and adjusting the vertical velocity based on raycast distance to make it behave like a hoverboard or car suspension. The benefit of that is you will be able to run over stairs and terrain bumps without friction and jitter while the capsule will still be blocked by higher colliders like it should.

    Best,
    Pärtel
     
  23. PlayingKarrde

    PlayingKarrde

    Joined:
    Aug 19, 2013
    Posts:
    28
    OK I think I understand now. The issue I was having (although not solved yet) is that my player1 is hitting the character controller collider. I'm not sure why but if I switch to a rigidbody it likely will be a moot point.

    However I'm still kind of confused how I can damage the other player without damaging the attacker. Do I just use the ragdoll colliders for this? I was thinking about putting a "collision" capsule collider on the attacker but this would then interact with the attacker too so that wouldn't work.

    Also, if I switch to a rigidbody system then I will need to animate the physics again right? That then brings me back to my issue of not being able to do so while using Animancer.

    -edit- (I previously wrote I was getting jerky animation with puppetmaster, but I resolved this by turning off fixed transformations
     
    Last edited: Sep 10, 2019
  24. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,965
    Hey,
    You should disable collisions for the character controller layer with itself in the Layer Collision Matrix. That way the ragdolls will be free to run into each other without the controller colliders blocking them.

    To make the attacker damage the victim without getting hurt you can use the Boosters.
    Deckare a public Booster booster; and fill it out in the Editor. You can use it to give temporary immunity and/or damage multiplier to a puppet. You trigger it by calling booster.Boost(behaviourPuppet); when you start the attack animation.
    The boosting effect will fall off over time, defined by "Boost Falloff" in BehaviourPuppet. Value of 1 means the effect will be gone in 1 second. That is how the punching and hitting (press E) is done in the Melee demo.

    You don't need to use AnimatePhysics with a rigidbody system. In the "Puppet Extended" demo you'll find another instance of the Pilot "ThirdPersonPuppet (Interpolated)", that is using Normal mode and has the controller rigidbody and all ragdoll rigidbodies set to interpolate.

    Best,
    Pärtel
     
  25. PlayingKarrde

    PlayingKarrde

    Joined:
    Aug 19, 2013
    Posts:
    28
    Oh I didn't know about Boosters. Perfect I'll dig into that - it sounds exactly like what I've been needing.

    I'll look at the demo you suggest but is that really the case if I'm using root motion? I am finding without animate physics I'm not getting the root to move or at least it doesn't move correctly it seems.
     
  26. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,965
    Hey,
    Might be that because the controller is a rigidbody, Normal mode doesn't apply root motion correctly to that rigidbody. Might need a script that accumulates animator.deltaPosition from OnAnimatorMode, then applies the accumulated value to the rigidbody in FixedUpdate:

    Code (CSharp):
    1. void OnAnimatorMove() {
    2. fixedDeltaPosition += animator.deltaPosition;
    3. }
    4.  
    5. void FixedUpdate() {
    6. Vector3 rootVelocity = fixedDeltaPosition / Time.deltaTime;
    7. rigidbody.AddForce(rootVelocity - rigidbody.velocity, ForceMode.VelocityChange);
    8. fixedDeltaPosition = Vector3.zero;
    9. }
    10.  
    11. }
     
    PlayingKarrde likes this.
  27. corjn

    corjn

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

    A question for my caress game again, I'm working on my grabbing system, with the help of puppetmaster. (Imagine a puppet arm attached to a fps camera). My puppet rigidbodies are in interpolate mode to avoid jittering.

    I'm looking for a way to fix in late update (like the camera movement) the root position of the puppet. If I move the puppetmaster transform in late update it's killing the rigidbodies interpolation for some reason. Of course another solution would be to set the mapping weight of the root/hips to 0, but If I do this the arm will jiggle to reach the position of my moving character/camera.

    I basically want my arm puppet to be affected by the camera rotation, not by it's movements. How would you do that ?

    Thanks in advance for your help :)
    Jonathan
     
    Last edited: Sep 17, 2019
  28. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    880
    :: Edit :: I believe I have this worked out. I added another bone to the ragdoll hierarchy and threw a script on it so I could easily reference it and grabbed the position of that and so far it seems to be working ok. ::


    Hey there Partel. I seem to be having an issue getting the correct world position of the ragdolls final resting place just before it begins the GetUp phase. I am using ECS and my Entity has a pathfinding and navigation system that moves the entity around and that position gets synced to the GameObject and plays the animation. I have it so that as soon as the character becomes unpinned it removes a "Movable" tag which stops the entity from following the path and playing the animation and then as soon as the character regains it's composure (BehaviourPuppet.State.Puppet) it adds the tag to continue moving.

    The problem I am having though is when the character becomes unpinned and the ragdoll gets moved to a new location, I am trying to update the entities position to match that of the ragdoll but I can't see to locate what position value to use.

    Here was what I was attempting to use:

    Code (CSharp):
    1.                 if (behaviourPuppet.state == BehaviourPuppet.State.Puppet)
    2.                 {
    3.                     var pos = puppetMaster.transform;
    4.                     localToWorld = new LocalToWorld
    5.                     {
    6.                         Value = float4x4.TRS(pos.position, pos.rotation, new float3(1.0f, 1.0f, 1.0f))
    7.                     };
    8.                     EntityManager.SetComponentData(e, localToWorld);
    9.                     EntityManager.RemoveComponent<IsUnpinned>(e);
    10.                     EntityManager.AddComponent<MovableTag>(e);
    11.                 }
    but that doesn't seem to be the one to use, I guess. It just seems to move the entity back to the location of where it became unpinned as you can see to the right side of the clip here. https://i.imgur.com/f6gaVk9.gifv What transform position should I be using to get the ragdolls actual position?
     
    Last edited: Sep 19, 2019
  29. UnitedBluff

    UnitedBluff

    Joined:
    Apr 19, 2015
    Posts:
    15
    Hello

    Just wanted to know, will upcoming versions of PM support the new ECS system and the new physics system as well? I have a feeling that Unity will completely phase out the old Monobehavior based system (it might take some time though), and as such, I kind of have a bad feeling starting a game based on that if the tools will not support future updates from Unity.
     
  30. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    880
    Monobehaviour will not be going away. It's just that primary focus will be on DOTS for performance optimization. They already said there is no plan to get rid of it. Plus, they aren't technically close to even being 'done' getting it out the door. *If* monobehaviour were to go away, it would not be for 7 years+
     
    Subliminum likes this.
  31. dmarot

    dmarot

    Joined:
    Jul 24, 2019
    Posts:
    5

    Dear Pärtel,
    Is there a way to implement muscle disconnecting & events using Playmaker? I'm able to use the Puppetmaster playmaker addon to set an individual muscles settings (pin weight & muscle weight) I cant figure out how to call this using the skeleton script. If it's more efficient to do it this way I'd rather go for efficiency anyway.
    - edit - I tried to use the set Property action, in combination with the Puppet Master Individual Muscle Settings PM action - and this seems like a start, however the targeted limb wont disattach, the target limb kind of just dangles. I have tried to using scripts re-create new scenes with all of the elements from the Disconnecting Muscles scene, I also tried copying a prefab of the cowboy skeleton to other scenes.. I have spent way too much time on this, however the function is one of the main reasons I bought both extensions (can provide invoice#'s). I've dissected the disconnecting muscles scene countless times, yet can't figure out what I am doing wrong. I've haven't had major issues figuring out functionality with my other assets. Are there any tips, suggestions, or videos of rigging a character from scratch to have a motion controller with limb severing? (btw I'm using ootii MC2 & other than getting the muscles to fully disconnect I have had no issues)

    Thanks in advance for any help you can provide
     
    Last edited: Sep 21, 2019
  32. UnitedBluff

    UnitedBluff

    Joined:
    Apr 19, 2015
    Posts:
    15
    Think it will come within a year at max. Unity cannot afford to avoid such massive gains in performance. As I understand it, the new physics system will not even work with the current one, so even if the old one still exists, their will be no interactions between the two systems, meaning two objects on two different system will simply pass through each other.
    I tried out a few examples and it's so different that I wonder where Monobehaviors would fit in.
     
  33. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    880
    What I am saying is, that it was Unity themselves that said that they have no plans to remove MonoBehaviour.

    Straight from the horses mouth, as they say:



    Also, here is a project I have been working on to learn DOTS. Vehicles and everything are 100% DOTS.
    https://i.imgur.com/a91Ky6O.gifv

    Then here is where I added DOTS Physics from the EntityComponentSystemSamples / Physics demos and have it working with PuppetMasters MonoBehaviours.

    https://i.imgur.com/tf4hQCV.gifv
    https://i.imgur.com/xduvgXD.gifv
     
    Last edited: Sep 22, 2019
    Partel-Lang likes this.
  34. nicosuave

    nicosuave

    Joined:
    Nov 16, 2015
    Posts:
    5
    Hey Partel,

    Thanks for making this package! I'm having an issue where the Biped Ragdoll Creator isn't creating the dual rig -- instead it attaches joint contraints and colliders to the existing armature. Any idea why this is happening/how to fix this?

    Attached is an example project -- just hit "Create a Ragdoll" on the cyclops character: https://www.dropbox.com/s/xvzqovt2pi4ilxf/rigger.zip?dl=0

    Thanks,
    Nick
     
  35. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,965
    Hey,
    You could try using PuppetMaster.OnWrite delegate to add the delta rotation of the camera to the model's root after PuppetMaster has already mapped the model to the ragdoll.

    Code (CSharp):
    1.  
    2. private Quaternion lastCamRot = Quaternion.identity;
    3.  
    4. void Start() {
    5. puppetMaster.OnWrite += OnPMWrite;
    6. }
    7.  
    8. void OnPMWrite() {
    9. Quaternion deltaRotation = camera.rotation * Quaternion.Inverse(lastCamRot) ;
    10.  
    11. puppetMaster.targetRoot.rotation = deltaRotation * puppetMaster.targetRoot.rotation;
    12.  
    13. lastCamRot = camera.rotation;
    14. }
    Not sure if it would actually work, so many unknown variables there. I'd look at your project if you could send it over.

    Hey,
    Using puppetMaster.transform.position will not work, PuppetMaster gameobject is basically just a folder for the ragdoll, it is only moved on some special occasions like when teleporting a puppet. You should use puppetMaster.targetRoot.position instead (the gameobject that normally has the Animator and the character controller). It will be moved and rotated to the ragdoll by BehaviourPuppet when it starts the getting up procedure.

    Hey,
    It is too early to say, Unity physics needs to mature quite a lot before it can support something as complex as active ragdolls properly. I will keep my eye on it though and if there is sufficient performance and stability to gain, I'll do my best to integrate.

    Don't worry about MB being removed, you can finish any game before (or if at all) that happens.

    Hey,
    When you disconnect an arm and have the PuppetMaster gameobject selected, do you see the colliders of the arm falling off or are they just dangling there as well? PuppetMaster muscle disconnection works only on the physics level, I mean it doesn't cut the SkinnedMeshRenderer. The skeleton character is not a skinned mesh character, it is basically just individual bone meshes parented to the bones. It will work with SkinnedMeshRenderers too, but the cutting of the skin needs a custom/3rd party solution.

    Best,
    Pärtel
     
    MostHated and corjn like this.
  36. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,965
    Hey,
    BipedRagdollCreator is not supposed to create the dual rig, it just creates the ragdoll. The dual rig is created by adding the PuppetMaster component and clicking on "Set Up PuppetMaster". Please follow this tutorial.

    Best,
    Pärtel
     
  37. alexkarak

    alexkarak

    Joined:
    Feb 7, 2018
    Posts:
    7
    Hey Partel
    I am trying to make my character throw props but when i try to find the rigidbody of the prop to add force to it it adds force to the character instead couse he is the parent of the prop and the props rigidbody is not there!

    Code (CSharp):
    1. void Throw()
    2.         {
    3.  
    4.            
    5.             Debug.Log("Boom");
    6.             puppetMaster.RemoveMuscleRecursive(lastProp.muscle, true, false, MuscleRemoveMode.Sever);
    7.             rb = currentProp.GetComponentInParent<Rigidbody>();
    8.             rb.isKinematic = false;
    9.             rb.transform.parent = null;
    10.             rb.AddForce(transform.forward * thrust,ForceMode.Impulse);
    11.         }
    12.     }
    This is the lines and i added this in Prop root script like this :
    if (currentProp != null && Input.GetMouseButtonDown(0))

    Throw();


    i cant figure out how to do this correctly
     
  38. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,965
    Hey,
    PuppetMaster has a brand new prop system, you should switch to that because it is much faster and more stable.
    Here's a tutorial.

    But to answer your question, you should not change PropRoot.cs, but instead make a new script like this:

    Code (CSharp):
    1. public PuppetMaster puppetMaster;
    2. public PropRoot propRoot;
    3.  
    4. void Start() {
    5. puppetMaster.OnMuscleRemoved += OnMuscleRemoved;
    6. }
    7.  
    8. void Update() {
    9. if (propRoot.currentProp != null && Input.GetMouseButtonDown(0)) {
    10. propRoot.currentProp = null;
    11. // Do not add force here, the muscle will not be removed before the next FixedUpdate.
    12. }
    13. }
    14.  
    15. private void OnMuscleRemoved(Muscle muscle) {
    16. muscle.rigidbody.AddForce(...);
    17. }
     
    alexkarak, Subliminum and MostHated like this.
  39. nicosuave

    nicosuave

    Joined:
    Nov 16, 2015
    Posts:
    5
    Thanks Pärtel, worked like a charm :)
     
  40. Deckard_89

    Deckard_89

    Joined:
    Feb 4, 2016
    Posts:
    205
    My player character can crouch, but when his puppet is knocked over, he will get back up and enter the standing idle animation before returning to the crouch state. This would not be a problem normally, but sometimes in the game there are places like small enclosed spaces where he is not able to physically stand, and so it's important he returns directly to the crouched state. Is there a way to do that with PM?
     
  41. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,965
    Hey,
    Yeah, no prob, you can do that in Mecanim. Go to the "BehaviourPuppet" sub-state machine in your animator controller. You should have GetUpProne and GetUpSupine animation states there with transitions to exit the machine and switch to the idle/locomotion state. If your character can crouch, you probably already have a "crouch" parameter in the controller.
    Just make 2 transitions - one going to normal locomotion and the other going to crouch locomotion, depending on the state of the "crouch" parameter.

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

    Deckard_89

    Joined:
    Feb 4, 2016
    Posts:
    205
    Excellent, thank you.
     
  43. AylaBVR

    AylaBVR

    Joined:
    Jun 21, 2019
    Posts:
    4
    In the "Killing" demo scene, there is a missing script on the game object called "GameObject". Partel, would you happen to know what this script should be?
    Thanks
     
  44. Deckard_89

    Deckard_89

    Joined:
    Feb 4, 2016
    Posts:
    205
    I have an issue with PuppetMaster in which major jittering occurs, but only sometimes, with no identifiable pattern to recognise what's causing it.
    I think, it seems to be worse only if the player's Animator's Update Mode is set to Normal, though I'm not sure enough to say it as fact.

    Also, could you make the Can Get Up option (in the Getting Up section of the Behavior Puppet) accessible to Unity Events? It would be a time saver to be able to just use call event and disable Can Get Up when the character is considered dead.
     
    Last edited: Oct 7, 2019
  45. alexkarak

    alexkarak

    Joined:
    Feb 7, 2018
    Posts:
    7
    Hey Partel
    I am so sorry to bother you again i hope this will be the last time
    I ve been trying so many days with the throwing system and honestly i bump into problems all the time...

    Code (CSharp):
    1.  
    2. using System;
    3. using System.Collections;
    4. using System.Collections.Generic;
    5. using UnityEngine;
    6. namespace RootMotion.Dynamics {
    7.     public class ThrowIt : MonoBehaviour
    8.     {
    9.         public PuppetMaster puppetMaster;
    10.         public PropRoot propRoot;
    11.  
    12.         internal void OnMuscleRemoved()
    13.         {
    14.             throw new NotImplementedException();
    15.         }
    16.  
    17.         public float thrust;
    18.         public Animator anim;
    19.  
    20.  
    21.         void Start()
    22.         {
    23.             puppetMaster.OnMuscleRemoved += OnMuscleRemoved;
    24.            
    25.         }
    26.  
    27.         void Update()
    28.         {
    29.             if (propRoot.currentProp != null && Input.GetMouseButton(1))
    30.             {
    31.                 anim.SetBool("IsAiming", true);
    32.  
    33.  
    34.  
    35.                 if (Input.GetMouseButtonDown(0))
    36.                    
    37.                 {
    38.                     anim.SetTrigger("Throw");
    39.                     propRoot.currentProp = null; }
    40.                 // Do not add force here, the muscle will not be removed before the next FixedUpdate.
    41.             }
    42.             else
    43.                 anim.SetBool("IsAiming", false);
    44.         }
    45.  
    46.         public void OnMuscleRemoved(Muscle muscle)
    47.         {
    48.             muscle.rigidbody.AddForce(Camera.main.transform.forward * thrust + transform.up * 2, ForceMode.Impulse);
    49.         }
    50.     }
    51. }
    52.  
    this is the script! So
    when my character throws the object and the object colides with another puppet it spawns back to my players hand!






    How can i write this down so that it will work? :/
     
    Last edited: Oct 9, 2019
  46. jfonz001

    jfonz001

    Joined:
    Jul 19, 2017
    Posts:
    12
    Hey Partel,

    I have a situation where I have a unit on top of a hill trying to swing a melee weapon down at a unit lower than him on the hill. I am calculating the angle of the aim based on an equation that looks at the y postion of each unit, however I am finding that the y position jumps around as the units move. This is happening in both my game and the Melee Demo:

    https://imgur.com/a/Yts9fxE

    It seems to be jumping around to the same few numbers. With Gravity = true on my rigidbody, the actually character controller itself does not appear to be moving, but the Y axis does (it can jump to as high as 5.0+ quite often).


    It seems that this is caused by the collider of the character controller colliding with the terrain. If you turn off gravity on the Rigidbody and raise the collider up so that it is no longer touching the terrain, the Y position stays put (usually at 0).

    However, I would like gravity to be enabled, do you know a way around this issue?

    Thank you.

    UPDATE:

    So I was actually playing around with your "melee sphere" demo and realized that the character there does not have that "y axis jumping/stuttering" issue. I had also noticed that when my player was on a hill in my own game, the issue went away...

    So what I did was place the entire terrain at y = 0.1 instead of 0.0...and the Y axis on my units is now much more stable! I can now use that value to calculate the angle of attack.

    The issue of the jumping on perfectly flat, y = 0 terrain still remains however, but I'm past this roadblock at least. 99.9% terrain will likely not be at 0.0 anyway, so we're all good.

    Thank you
     
    Last edited: Oct 11, 2019
  47. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,965
    Hey,
    You can just get rid of that, it was just a little debugging script to reduce time scale, I must have saved the scene by accident after debugging it.

    Hey,
    Usually jitter happens when the camera is not in sync with the object that it is tracking. If it is normally smooth, it might be that it goes out of sync when there is a collision with the ragdoll and BehaviourPuppet blends in the mapping for a while. That scenario can happen only you have BehaviourPuppet's Normal Mode set to Unmapped or Kinematic. Please try setting your ragdoll rigidbodies to Interpolate.

    Also make sure your camera controller script updates in LateUpdate and it is assigned to a higher value in the Script Execution Order than PuppetMaster.cs has.

    Hey,
    I really can't think of a reason why it should spawn back to the player's hand, haven't seen that one before.
    Maybe there is a bug in your prop picking up code instead, something that sets propRoot.currentProp. So maybe search the entire solution for ".currentProp = " to see if there might be something calling to pick up the prop after it has already been removed.

    Hey,
    Based on your screenshot, I think you see it jumping around only because you have your handle position tool set to Center, not Pivot.
    Pivot tool.JPG
    If you switch it to Pivot, you should be the handle fixed at the ground level where the character Transform actually is.

    Best,
    Pärtel
     
    Deckard_89 likes this.
  48. alexkarak

    alexkarak

    Joined:
    Feb 7, 2018
    Posts:
    7
    Hey ...i think i fixed it! I have one more question though! i ve added a throw animation and i want to make the OnMuscleRemoved being called in the middle of the animation but i cant reference to the function from the animaton controller gameobject! How can i make the event work? I ve tried to make a script calling the OnMuscleRemoved from the child but it doesnt work!
     
  49. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,965
    Hey,
    You should add an animation event "Throw" to your throwing clip in the animation import settings. Then add a script on the Animator's gameobject with this:

    Code (CSharp):
    1. public PropRoot propRoot;
    2.  
    3. public void Throw() {
    4. propRoot.currentProp = null;
    5. }
    Then OnMuscleRemoved will be called by PuppetMaster when the prop muscle is removed.

    Best,
    Pärtel
     
  50. alexkarak

    alexkarak

    Joined:
    Feb 7, 2018
    Posts:
    7
    I tried it and it still throws it the moment i press left click without waiting for the animations frame were the event is set :/

    It also does a weird thing with the throw trigger! When i aim and the aim animation ends when i press right click to throw , the animation of throw doesnt play but my player throws the prop and the trigger of the throw is still pressed! And when i pick up the prop and aim again as soon as the aim animation ends it throws the object directly (withou pressing throw) and the throw happens on the right frame but only then!



    Code (CSharp):
    1. using System;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. namespace RootMotion.Dynamics {
    6.     public class ThrowIt : MonoBehaviour
    7.     {
    8.         public PuppetMaster puppetMaster;
    9.         public PropRoot propRoot;
    10.  
    11.         internal void OnMuscleRemoved()
    12.         {
    13.             throw new NotImplementedException();
    14.         }
    15.  
    16.         public float thrust;
    17.         public Animator anim;
    18.  
    19.  
    20.         void Start()
    21.         {
    22.             puppetMaster.OnMuscleRemoved += OnMuscleRemoved;
    23.          
    24.         }
    25.  
    26.         void Update()
    27.         {
    28.             if (propRoot.currentProp != null && Input.GetMouseButton(1))
    29.             {
    30.                 anim.SetBool("IsAiming", true);
    31.  
    32.  
    33.  
    34.                 if (Input.GetMouseButtonDown(0))
    35.                  
    36.                 {
    37.                     anim.SetTrigger("Throw");
    38.                     propRoot.currentProp = null; }
    39.                 // Do not add force here, the muscle will not be removed before the next FixedUpdate.
    40.             }
    41.             else
    42.                 anim.SetBool("IsAiming", false);
    43.         }
    44.  
    45.         private void OnMuscleRemoved(Muscle muscle)
    46.         {
    47.             muscle.rigidbody.AddForce(Camera.main.transform.forward * thrust + transform.up * 2, ForceMode.Impulse);
    48.         }
    49.     }
    50. }
    51.  
     
    Last edited: Oct 14, 2019