Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

PuppetMaster - Advanced Character Physics Tool [RELEASED]

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

  1. ChaosriftGames

    ChaosriftGames

    Joined:
    Aug 25, 2017
    Posts:
    11
    Problem i'm having.

    Using Invector Shooter
    I have layers, Ground, Projectile, Ragdoll, Enemy, player.
    Puppet Master character uses Enemy for the character. Ragdoll for the puppetmaster stuff. Ground for ground.

    I blow up a barrel it properly applies force. Ragdoll goes flying. But it then snaps back to the original standing point.
     
    Last edited: Sep 17, 2018
  2. cspid

    cspid

    Joined:
    Apr 25, 2014
    Posts:
    13
    Hi Partel - having a bit of an issue working with Puppetmaster and the Ootii controller. I've run the package and set up the puppet with the ootii puppet script, but I get strange behaviour when the character gets up from a fall - he springs back to a standing position instead of doing the recovery animation and then is unable to move for a few seconds. Do I need to fix something in the animator? Thanks.
     
  3. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,755
    Hey, sorry for the delay, was on a brief vacation.

    There isa brand new EULA since Sept 14 and they have clarified this particular issue (see 2.4).

    Hey,
    Haven't tried Invector Shooter, but I have just updated Ivector's Third Person Controller integration package.
    If it snaps back to where it fell, it's probably because Invector's controller forces it there. The controller needs to be disabled while the puppet is unpinned.

    Hey,

    You'll have to copy the "BehaviourPuppet" and "BehaviourFall" Sub-State Machines from the "Humanoid Third Person Puppet" animator controller to the controller used by your character and make a state machine transition from "BehaviourPuppet" to the idle or locomotion state of your controller.

    Also just recently updated the Ootii integration package.

    Best,
    Pärtel
     
  4. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    272
    Hey Partel,

    is it possible to simulate the ragdoll behaviour in a single frame? What I'm trying is to show spawned dead npcs on ground (without any death animation or ragdoll) for players who join my game server.
     
  5. fornetjob

    fornetjob

    Joined:
    Sep 11, 2014
    Posts:
    13
    How I can disable a puppet's leg if it is shot by a player, for example?
     
  6. fornetjob

    fornetjob

    Joined:
    Sep 11, 2014
    Posts:
    13
    Im bougth FinalIK, but hit reaction not working. How to set hit reaction (shoot) in PuppetMuster with Final IK(or without), without fall?

    Code (CSharp):
    1. NullReferenceException
    2. UnityEngine.Transform.get_rotation ()
    3. RootMotion.FinalIK.HitReaction+HitPointBone+BoneLink.Apply (RootMotion.FinalIK.IKSolverFullBodyBiped solver, Quaternion offset, Single crossFader) (at Assets/Plugins/RootMotion/FinalIK/Tools/HitReaction.cs:167)
    4. RootMotion.FinalIK.HitReaction+HitPointBone.OnApply (RootMotion.FinalIK.IKSolverFullBodyBiped solver, Single weight) (at Assets/Plugins/RootMotion/FinalIK/Tools/HitReaction.cs:201)
    5. RootMotion.FinalIK.HitReaction+HitPoint.Apply (RootMotion.FinalIK.IKSolverFullBodyBiped solver, Single weight) (at Assets/Plugins/RootMotion/FinalIK/Tools/HitReaction.cs:73)
    6. RootMotion.FinalIK.HitReaction.OnModifyOffset () (at Assets/Plugins/RootMotion/FinalIK/Tools/HitReaction.cs:230)
    7. RootMotion.FinalIK.OffsetModifier.ModifyOffset () (at Assets/Plugins/RootMotion/FinalIK/Tools/OffsetModifier.cs:95)
    8. RootMotion.FinalIK.IKSolver.Update () (at Assets/Plugins/RootMotion/FinalIK/IK Solvers/IKSolver.cs:56)
    9. RootMotion.FinalIK.IK.UpdateSolver () (at Assets/Plugins/RootMotion/FinalIK/IK Components/IK.cs:27)
    10. RootMotion.SolverManager.LateUpdate () (at Assets/Plugins/RootMotion/Shared Scripts/SolverManager.cs:113)
    11.  
     
    Last edited: Sep 27, 2018
  7. ChaosriftGames

    ChaosriftGames

    Joined:
    Aug 25, 2017
    Posts:
    11
    So here's my test scene. I swapped to Emerald AI for this. The big guy to the far left fell down and rolled a bit, which was awesome. But he left his Box Collider and Navmesh Agent far behind as seen in the picture.

    This happens regardless of if I wrote my own character script or using a precanned AI script.

    Also, once they stand back up, they remain separated from their collider and navmesh. I'm assuming in code you could just have it cache the local coordinates and snap them back together after a fall is in the recovery phase.



     
  8. Termotank

    Termotank

    Joined:
    Sep 1, 2015
    Posts:
    6
    Hi Partel, awesome work! Just a small question.

    Is it possible to connect Leap Motion with your plugin?

    If yes, TAKE MY MONEY PLEASE!
     
  9. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,755
    Hey guys, sorry for the delay, been traveling to the States for Oculus Connect 5.

    Hey,
    Not really. You could sync localRotations of the ragdoll bones on initiation though.

    Hey,
    Set muscle.props.pinWeight to 0 and reduce muscle.props.muscleWeight for the leg muscles.
    You can use puppetMaster.SetMuscleWeightsRecursive for that.
    Would also be good to switch to some kind of hopping on one leg animation like when you shoot a leg off the skeleton in the "Removing Muscles" demo.

    Hey,
    HitReaction will produce this error if there is a missing bone reference. Expand the "Bone Hit Points" in the bottom of HitReaction, then also expand "Bone Links" and you should see a missing bone under "Element 0".

    Hey,
    The NavMeshAgent or any other AI script needs to be on the Target Root gameobject (the one that has the Animator), not the root of the entire rig (that is just a folder for the rig and should not be moved). That is usually the cause of problems like this. I have also just made a demo for NavMeshAgent for the next version of PM.

    Hey,
    I don't have an integration tool for PM and LeapMotion, sorry. Technically it should be possible though, PM can be used on any ragdoll hierarchy.

    Best,
    Pärtel
     
  10. ChaosriftGames

    ChaosriftGames

    Joined:
    Aug 25, 2017
    Posts:
    11
    Pärtel

    Welcome to the States!

    Tried it out. Even the punching dummies from your sample scenes do this. The Root where the original skeleton and model were shifts out of place while the top level parent and puppetmaster portions stay in place. So puppetmaster will be at 0,0,0 local to the parent and the Root with animator and scripts will be like 0.9,0,2 Local coordinates.

    I'm using a simple explosion that applies force which knocks these guys around. Also a character just tripping will also shift from the 0,0,0. I love all these effects and hope I can get everything working for my game.
     
  11. Chris45215

    Chris45215

    Joined:
    Jan 30, 2016
    Posts:
    6
    Partel, thanks and I just got the second license.

    I'm trying to implement the system on some AI enemies, a lot like the Melee demo scene that is included with puppetmaster, but I've having some difficulty because the enemies don't turn unless they are also moving forward. If there's a simpler way that I should implement this, or some easy-to-integrate melee enemy movement controller in the asset store, please let me know! Otherwise, if using that Melee demo scene as the example, you should be able to recreate the issue by setting the parameter Bot Puppet -> Character Controller -> User Control AI -> Stopping Distance to a higher value like 3. Then, run the scene, and after the bot stops, move the user-controlled puppet forward and slightly past Bot Puppet. As long as you stay within the stopping distance, Bot Puppet won't turn to face the target. It seems that he only turns when he's also walking forward, even though the animation blend tree includes animations to turn without changing position.

    I've been trying to isolate the cause, but the scripts are far smarter than I am, so I could use a hand. I've gone through some of the CharacterAnimationThirdPerson script, and the function GetAngleFromForward() returns 0 during the "should turn but doesn't" situation. So, line 64 runs with the values animator.SetFloat("Turn", 0). I'm not sure if that causes the problem. But I can't even grasp how GetAngleFromForward() works because it seems like it's just calling Vector3 local = transform.InverseTransformDirection(transform.forward) but the transform.forward is from the prior frame, so is that just calculating the change in transform.forward from one frame to the next? But deltaAngle is subtracted from the result of that, and I thought deltaAngle was the change between frames. I can't even start to understand how all this works, or how OnAnimatorMove() comes into it, but it all seems to relate.

    I'm guessing this all ensures that the controller moves and rotates in sync with the animation. But could that be done more simply by applying the root motion of the animations? Or is the entire system made so that the animation does the turning (to allow different animations to be put in very easily) and then the scripts figure out when to stop turning?
     
  12. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,755
    Hey,
    Sorry I think I don't fully understand. Could you tell me the exact steps to reproduce it in one of the demo scenes?

    Hey,
    First go to UserControlAI.cs and add this line:
    Code (CSharp):
    1. state.lookPos = moveTarget.position;
    Then enable "Look In Camera Direction" in CharacterThirdPerson component.
    And finally, set "Turn Sensitivity" to 2 and "Turn Speed" to 2 in CharacterAnimationThirdPerson component that is on the gameobject that has the Animator.

    Best,
    Pärtel
     
  13. pan4ezzz

    pan4ezzz

    Joined:
    Jul 9, 2017
    Posts:
    12
    Hey Pärtel,
    asset is awesome, but listen unity physics is not predictably, especially for network. So can you help with behaviour for getting up only, like BehaviourFall for only one decision - getting up and ending
     
  14. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,755
    Hey,
    If you are trying to get PM networked, there's an UNet example included under "Plugins/RootMotion/PuppetMaster/_Integration", that might help.

    But about just getting up, the way BehaviourPuppet does it, is move the animated character to the position of the pelvis rigidbody, check if the ragdoll is in a prone or supine pose by checking the dot product of pelvis forward and Vector3.up (line 12 in BehaviourPuppetHelpers.cs and the 2 blocks starting from line 135 in BehaviourPuppetStateSwitching.cs) and play a prone/supine get up animation according to that. Then just gradually weigh in the pin weight.

    Best,
    Pärtel
     
  15. devis

    devis

    Joined:
    Aug 23, 2014
    Posts:
    28
    Hi! I noticed that the Intergration with Invector's Controller doesn't really work anymore. Im using the Shooter version.
    Not at all actually. When you create the Puppet using the script provided, it does create the puppet
    but the Puppet is not following the character. It just stays in place and seems to be stuck on torso level.
    Another issue is that the character starts to sink to ground via also stretching the legs?
    And when you do get hit, the character goes insane and stretches all over the place.

    I also get error to console about having the Controller and Puppet at same place, but they ARE at same place when the scene starts. Any ideas? I fixed the namespace errors that were there, it worked the first time perfectly but now it doesn't work at all.
     
  16. Utopien

    Utopien

    Joined:
    Feb 15, 2016
    Posts:
    12
    Hello I'm wondering if puppet master can be efficiency sync to a network like photon it seems to have many values the sync with a game up to 20 or 30 character at the same time is a reasonable?
     
  17. PicturesInDark

    PicturesInDark

    Joined:
    Jun 13, 2013
    Posts:
    73
  18. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,755
    Hey,

    The Invector package in current PuppetMaster is out of date, as they have updated their stuff. Here's the latest I have from 1-2 months ago.

    Hey,
    It's like with any ragdoll physics networking. There is a basic UNet demo included in the package under Plugins/RootMotion/PuppetMaster/_Integration. So in that demo, the ragdolls are not synced all the time. Ony when BehaviourPuppet goes into Unpinned state (puppet loses balance), then the ragdoll syncing will start and lasts until it gets up again. On the remote end, BehaviourPuppet will never lose balance on it's own, just when it gets an RPC to do so from the owner. So the remote client is locally simulated for the most part.

    That said, you should not expect to have 30 puppets active simultaneously anyway, due to CPU performance.

    Best,
    Pärtel
     
    Utopien likes this.
  19. mrstruijk

    mrstruijk

    Joined:
    Jan 24, 2018
    Posts:
    7
    Hi Pärtel!

    Maybe I missed this in the tutorials or documentation, but how can I add (working) colliders to the existing ragdoll? I need to use the hands pretty extensively, and while working with the Manus, the physics doesn't seem to update.

    I copied the joints from the model hand, pasted them under the hand in the PuppetMaster section, and added the colliders, configurable joint and rigidbody.

    I tried changing the script execution order, but that didn't seem to do the trick.
    ezgif.com-optimize (1).gif

    Best,
    Maarten
     
  20. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,755
    Hey,
    You also have to add those additional joints to PuppetMaster muscles. Expand the "Muscles" array on the bottom of PuppetMaster and add them in there.
     
  21. PicturesInDark

    PicturesInDark

    Joined:
    Jun 13, 2013
    Posts:
    73
    That is what happens also with Tactical AI. Is any posibility you research integration PM with Tactical AI? In my videogame: https://store.steampowered.com/app/910430/The_War_of_the_Worlds_Andromeda/
    I'm having a lot of criticism among other things because I do not just integrate or adjust well PM, FInal IK and Tactical AI.

    I have managed to integrate it but in a way that is not realistic. So they are calling me the video game as garbage. To see if you could help me a little, I would be very grateful.
     
  22. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    385
    Partel,

    I just installed your current release and I noticed the following Improvement:
    "- Added OnCollision delegate to BehaviourPuppet to enable you to get collision event calls from the muscles even if those collisions have not resulted in a loss of pinning for the puppet."

    - Can you please explain the use of Collision Resistance Multipliers with both OnCollision and OnCollisionResistance events? (Specifically how the Multiplier and Collision Threshold values effect both events)

    I use OnCollisionImpulse to receive muscle collisions and Collision Resistance Multipliers to regulate which physics layers result in collisions and unpinning from the collision. If my Collision Resistance Multiplier value is low, OnCollisionImpulse is called every time there is any collision with a muscle, regardless of unpinning. I have a a lot of effects where I use those collisions when the character is not unpinned.

    So what is the point of OnCollision? It appears to me that OnCollisionImpulse already receives every collision depending on your use of collision resistance multipliers.

    Thanks
    Allan
     
  23. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,755
    Hey,
    Sometimes users need to get the collision information for some FX stuff regardles of how strong the impulse or which the state of the puppet at the time of collision. That is what OnCollision is for, it just forwards the collision info, which is better than adding another script to all the muscles with another OnCollisionEnter/Stay callback.
    OnCollisionImpulse however is only called if all conditions to do some damage to the puppet are met. For example it doesn't get called when the behaviour is disabled, state is Unpinned, colliding object layer is not included in the Collision Layers and so forth. (I guess I should have named it OnMuscleDamage or something like that).
    It's all in the protected override void OnMuscleCollisionBehaviour(MuscleCollision m) in BehaviourPuppetDamage.cs, line 33, if you'd like to take a look.

    Best,
    Pärtel
     
  24. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    385
    Ah yes I see.

    OnCollision happens first before any of the other checks in OnMuscleCollisionBehaviour so the event gets fired regardless of anything else including calculation for impulse so it happens before the Collision Resistance Multiplier settings.

    Thanks for the explanation.
    Allan
     
  25. mrstruijk

    mrstruijk

    Joined:
    Jan 24, 2018
    Posts:
    7
    Hi Pärtel,
    The new joints are represented in the Muscles array as well, since I set up the joints prior to setting up Puppetmaster, so they are automatically added by the system.

    What else can I check to make this work?

    Thanks for your excellent support man!
    Best,
    Maarten
     
  26. Mikekan13

    Mikekan13

    Joined:
    May 30, 2015
    Posts:
    41
    Hiya! I am trying to figure out how I can detect a raycast on a puppet. Usually, if you have complex colliders you would just have the parent have the rigid body and then it could detect the raycast. Since the puppet has a rigidbody for each body part you can't really do that. Is there an easy way to reproduce this or do I have to have a detector on each body part that then speaks to an overall body controller that can tell when any part is hit by a ray?
     
  27. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,755
    Hey,
    There's an example in the "Puppet Raycast Hit" demo, the code is in RaycastShooter.cs. You can detect which muscle was hit by using the muscleIndex of the MuscleCollisionBroadcaster component that you can get from the collision.attachedRigidbody object.

    Best,
    Pärtel
     
  28. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    271
    Hello there,

    Are there any plans on integrating Opsive TPC V2?
    I searched here and didn't see anything related to that question.

    TPC2 is apparently a complete rewrite of the original so I believe the existing integration wouldn't work
     
  29. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,755
    Hey,
    Yes, it is in my todo list. I wish I knew they were about to release v2 shortly after I last updated that integration. I'll ask them for a voucher...
     
  30. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    966
    I've created a character with all final ik and puppet master setup. Now I need to create another NPC character! should I do all the progress again for the new characters?
     
  31. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,755
    Hey,
    If you did it by hand in the Editor, then yes. It is possible to automate the process via scripting though, which you should do if you have many characters that don't share the same bone structure. Please take a look at the "Creating Ragdolls in Runtime" and "Creating Puppets in Runtime" demos to see how.
     
    ksam2 likes this.
  32. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    966
    Thanks but all my characters use the same bone structure. I thought maybe it's bad for performance to have 100 of characters with all those PuppetMaster and Behaviours as child on each of them.
     
  33. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,755
    If they have the same bone structure, can't you just have different SkinnedMeshRenderers for each character that you can activate/deactivate?
     
    ksam2 likes this.
  34. Tmtakala

    Tmtakala

    Joined:
    Mar 12, 2014
    Posts:
    9
    Hello,
    I just recently got Puppetmaster, and I'm hoping to get it to work with all 10 fingers, in addition to the whole body.
    Has anyone else done this? Are there any guides to this? Do I need to modify PuppetMaster scripts and how much work will that be?
     
  35. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,755
    Hey, thanks for the purchase!
    I haven't tried this myself, as there are so many bones in the fingers and having active physics on each one would be very expensive. Also, PhysX joints get more unstable the longer the joint chains are. Since PhysX joints are terribly unstable to begin with (since the "optimizations" added in Unity 5), I'm not sure if it would be a good idea. Might be a better way to achieve whatever you need to do kinematically, so if you told me more, I might have some suggestions for you.

    But if you wish to try, technically it's possible. The fingers need to be set up with rigidbodies, joints and colliders manually though. PuppetMaster can only work with ConfigurableJoints, but you can set them up with other joints, then select the root and go GameObject/Convert To ConfigurableJoints. Then you'll have to expand the Muscles array on the bottom of PuppetMaster and add the finger muscles in.

    Best,
    Pärtel
     
    ksam2 likes this.
  36. farzaan090

    farzaan090

    Joined:
    Jul 23, 2018
    Posts:
    1
    What timing! I believe I just sent you a support email in hopes of avoiding putting OnCollissionEnter scripts to each ragdoll child component.

    How exactly do I access the OnCollision function? Also, is it able to tell me which body part was hit and what it was hit by?

    Thanks!
     
    Last edited: Nov 26, 2018
  37. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,755
    Hey,
    Code (CSharp):
    1. void Start() {
    2. behaviourPuppet.OnCollision += OnCollision;
    3. }
    4.  
    5. private void OnCollision(MuscleCollision m) {
    6. // Access the collision: m.collision
    7. // Access the muscle: behaviourPuppet.puppetMaster.muscles[m.muscleIndex]
    8. }
    Oh btw, you might want to check out Unity 2018.3.0b11, they FINALLY fixed the memory allocation problems with OnCollisionEnter/Stay/Exit that used to give us nasty GC spikes :)

    Cheers,
    Pärtel
     
    AthrunVLokiz likes this.
  38. Tmtakala

    Tmtakala

    Joined:
    Mar 12, 2014
    Posts:
    9
    Thanks for your reply! I will be using realtime mocap as input for puppetmaster, including the fingers. I will have only one puppeted humanoid.

    The idea is that the when grasping virtual objects the fingers would stick and hold the object via friction, but as I haven't tried this yet, I'm concerned about the stability as you mentioned.

    In Puppetmaster, is it possible to start the "puppeted" joint chains from shoulders/hips? And have separate chains for each limb? Torso joints can be kinematic if that improves stability. Ideally the whole body would be a joint chain puppet... Would pinning shoulders and hips improve stability?

    Anyway, I'll start learning Puppetmaster in the coming days, so I'll probably have more accurate questions later.
     
  39. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,755
    Hey,
    You can't have part of the puppet kinematic and part non-kinematic. Pinning weights can be set for each muscle individually though, so you can have the body pinned to the animation (just AddFoce moving the muscles to their targets basically), and the fingers actuated only by muscle torques. If you wish to have arms puppeted only, you can do so, but setting up an independent PuppetMaster for each arm. The holding with friction should work and if the stability is bad, you can pump up the solver iteration count until it's better.

    Best,
    Pärtel
     
  40. JacobDzwinel

    JacobDzwinel

    Joined:
    Dec 19, 2013
    Posts:
    13
    Hi Partel,
    Is it possible to set Puppet immediately to Kinematic or Active. I want to switch quickly beetwen these both but it seems like i have to wait a frame or two to make it happen even on blend time set to 0.

    Thanks!
     
    Last edited: Nov 29, 2018
  41. JakeC

    JakeC

    Joined:
    May 3, 2014
    Posts:
    5
    Hi Pärtel,

    I just started using PuppetMaster yesterday so I am still learning how it works. I am developing a shooter, and I want to make it so when the enemies are shot (hitscan projectiles) they respond to impact but never get knocked down. For example, if the enemy is shot in the left arm, I want their body to swing to the left and then return back to their normal position. Ideally the enemy would stagger backward and regain balance and then keep fighting, but I saw a post you made earlier in this thread where you said that is a difficult feature to implement.

    Right now I am using BehaviourPuppet. I am calling MuscleCollisionBroadcaster.Hit() manually after I do a raycast to determine that a bullet has hit the enemy. I do not want the enemies to fall down ever, except when they die.

    * Update: I've found that if I set the knockout distance to something really high for all of the muscle groups then the puppet never falls over. At first I thought knockout distance didn't apply to collisions initiated by manually calling MuscleCollisionBroadcaster.Hit().

    I see BehaviourAnimatedStagger, but I don’t see any examples or documentation for it.

    Am I going about this the right way?
     
    Last edited: Nov 30, 2018
  42. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,755
    Hey,
    PuppetMaster is pretty much like a state machine, it depends on the update order of the Animator and the physics simulation so it needs to do things in a very specific order. That is why when you switch modes, it will only raise a flag and the mode is actually switched in the next frame. Could you tell me more please about the problem you are facing so I could make a test scenario and hopefully find a solution for you.

    Hey,
    Yeah, you can set behaviourPuppet.knockoutDistance to Mathf.Infinity, so it would never lose balance.

    As for staggering and regaining balance from that, that is to be faked with animation. You could lower the pin weights for the upper body and add some drag or damper to the muscles during that to give it a more ragdollish look.

    BehaviourAnimatedStagger was an experiment to see if I could use animation and gradually loosen it to create a stagger to fall effect, but I couldn't make it easy enough to set up for everybody so actually it made it into the package by accident.

    Best,
    Pärtel
     
  43. JacobDzwinel

    JacobDzwinel

    Joined:
    Dec 19, 2013
    Posts:
    13
    I'm using PuppetMaster to simulate ragdoll behaviours only when my character get unpinned, but not from PuppetBehaviour logic, i set it state (Unpinned) by myself. Most of the time, my puppetmaster is set to kinematic. I change it mode when my character get in unconscious state (my own FSM), i want to change PuppetMaster state from Kinematic to Active and unpin it. In the same frame I'm also subscribing to PuppetBehaviour events.

    Code (CSharp):
    1. Physics.SetPuppetMode(PuppetMaster.Mode.Active);
    2. Physics.PuppetBehaviour.SetState(BehaviourPuppet.State.Unpinned);
    3. Physics.PuppetBehaviour.onRegainBalance.unityEvent.AddListener(RegainBalance);
    4. Physics.PuppetBehaviour.onGetUpProne.unityEvent.AddListener(GetUp);
    5. Physics.PuppetBehaviour.onGetUpSupine.unityEvent.AddListener(GetUp);
    6.  
    From what i checked in your code, setting State to unpinned is happening immediately because it's sets muscles pinweight to 0. My problem is that changing PuppetMaster mode from kinematic to active fire onRegainBalance event in the next frame changing my unpinned state back again to puppet and leaves my custom FSM state. It's not a big problem because I can listen to PuppetMaster isActive property and then set unpinned state and subscribe to events, but i thought there is a another way simplier way.

    By the way, can I leave BehaviourPuppet normalMode set to Active while having PuppetMaster mode set to Kinematic? I want to make sure that there are no unnecesary calculation on all behaviours while i have my PM set to Kinematic.
    Should i change normalMode from BP or mode from PM?

    Thanks!
     
  44. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,755
    Hey,
    In BehaviourPuppet.cs, should be line 561, you'll find:
    Code (CSharp):
    1. if (!puppetMaster.isActive) {
    2.                 SetState(State.Puppet);
    3.                 return;
    4.             }
    Please change it to:
    Code (CSharp):
    1. if (!puppetMaster.isActive && !puppetMaster.isSwitchingMode) {
    2.                 SetState(State.Puppet);
    3.                 return;
    4.             }
    and please let me know if it makes the onRegainBalance event call go away.

    About the normalMode, yes you can leave it on Active, it doesn't process in Kinematic mode.

    Best,
    Pärtel
     
  45. Runetass

    Runetass

    Joined:
    Jun 4, 2013
    Posts:
    16
    Hey! Love your tool, been using it on and off for some years, mostly to play around. But I'm trying to see if it's viable to use for one of our games now.

    I'm looking into self-balancing ragdolls. My goal is to be able to stand and move around with a completely un-pinned ragdoll, without tipping over automatically. My preferred way would be to somehow solve this with internal torques, instead of having the puppet be suspended in air with the feet kind of dangling below. That way the puppets have real weight to them. A bit like the DeepMotion videos, I suppose.

    I noticed that you have a sub-behaviour SubBehaviourBalancer, but I don't undertand what I'm supposed to feed into it, judging by the function signature:
    Initiate(BehaviourBase behaviour, Settings settings, Rigidbody Ibody, Rigidbody[] rigidbodies, ConfigurableJoint joint, Transform[] copPoints, PressureSensor pressureSensor)


    What is Ibody? What rigidbodies do I pass as an array? copPoints (center of pressure points?) Would this be the feet (and as an array, to support multiple limbs in contact with the ground)? I understand roughly the purpose of PressureSensor, but only one? How would I set up this PressureSensor?

    And perhaps most importantly, is this sub-behaviour what I'm looking for? If not, I'm interested to hear in rough terms your opinion on the best technique for balancing un-pinned ragdolls. I understand that real balance keeping is a matter of torques, but not to what extent and which body parts must be involved for a rough simulation, and how the forces should be applied.

    One more question at the end - if I started applying torques to unpinned joints, wouldn't they still conflict with the torques maintained by PuppetMaster to match the pose of its animated counterpart? In light of this, an alternative strategy could be to instead attempt to rotate joints of the reference skeleton, since PuppetMaster matches those poses - but I'm still unsure how to proceed. I've not had much luck rotating only the foot joints in order to stay upright, so I'm guessing it's more complicated as a starting point.
     
  46. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,755
    Hey,
    If you import the "Final IK' integration package from Plguins/RootMotion/PuppetMaster/_Integration (requires Final IK to work), you'll get BehaviourbipedStagger.cs, that uses the balancers. SubBehaviourBalancer adjusts ankle joint's targetAngularVelocity to make a standing ragdoll (try to) maintain balance. Real humans of course use all the muscles to maintain balance, but we are developing games so we can't calculate all that each frame, so only the ankle joints are used. But it should be enough to make the ragdoll maintain balance with most standing, idle and even crouching idle animations. The initiation of the balancers and pressure sensor goes like this (copied from BehaviourBipedStagger):

    Code (CSharp):
    1. foreach (Muscle m in puppetMaster.muscles) {
    2.                 if (m.props.group == Muscle.Group.Foot) {
    3.                     System.Array.Resize(ref balancers, balancers.Length + 1);
    4.                     balancers[balancers.Length - 1] = new SubBehaviourBalancer();
    5.  
    6. PressureSensor pressureSensor = m.transform.gameObject.AddComponent<PressureSensor>();
    7.                     pressureSensor.layers = groundLayers;
    8.  
    9.                     balancers[balancers.Length - 1].Initiate(this as BehaviourBase, balancerSettings, m.joint.connectedBody, rigidbodies, m.joint, copPoints, m.joint.GetComponent<PressureSensor>());
    10.  
    11.                  
    12.                 }
    13.             }
    So the Ibody is the calf rigidbody, that is used for estimating the inertia tensor, "rigidbodies" are all the rigidbodies of the puppet, "joint' is the ankle joint, "copPoints" are the foot muscle transforms and the last parameter is the PressureSensor that should be on the foot muscle gameobject. There must be a SubBehaviourBalancer for each foot.

    If you are looking to create fully self-balanced ragdolls that are able to move around like humans, you might be severely underestimating the task though. It would require neural networks and machine learning, at least a year of time and a couple of computer engineering professors in your team to accomplish that.

    Cheers,
    Pärtel
     
    Runetass likes this.
  47. Runetass

    Runetass

    Joined:
    Jun 4, 2013
    Posts:
    16
    Hey, thanks for the reply!
    I wasn't aware of the Final IK integration package (I happen to also have FinalIK), so that helps.

    They seem quite fragile in the stagger demo, which is understandable. I think I have a rough idea how to test out the balancers in isolation now though. I'll experiment a bit more with techniques to maintain balance. I imagine the most important steps would be to rotate the feet forward onto the toes when leaning forward, and rotating back onto the heel when leaning backwards, and so on. In addition rotating the hip/spine, and finally adjusting footing to get a more stable pose if unable to stay balanced.

    I have been thinking a ML agent could be a worthwhile experiment, doing something like what's done in the demo where they balance a ball on a platform... just for multiple joints.

    I'm of course looking for an approximation. In any case, the fallback solution will of course be to fake it in a more obvious way. Balloon physics, constraining the hip's rotation, partial pinning etc, or even switching between pinning and unpinning.

    For reference, Exanima is a good example of the kind of stability I'm interested in. Let me know if you have ideas I haven't listed here, thanks for your help!
     
  48. ColtonK_VitruviusVR

    ColtonK_VitruviusVR

    Joined:
    Nov 27, 2015
    Posts:
    130
    Hey @Partel-Lang,

    Just picked up Puppet Master and so far so good, brilliant asset! I would like to leave the puppet master disabled until the enemy takes damage and then apply some kind of force for them to react too, is this possible? Currently I am thinking 1. Activate puppet master. 2. Fade mapping 0->1. 3. Apply a force to one or all rigidbodies attached to the ragdoll where the damage happened? Should I do it some other way?

    Cheers,
    Colton
     
  49. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,755
    Hey,
    Just applying force would have little effect as the puppet is pinned to the animation normally (just AddForce commands moving the muscles to their targets). I'd suggest you check out the "Puppet Raycast Hit" demo and use MuscleCollisionBroadcaster.Hit() like in the RaycastShooter.cs script.

    Cheers,
    Pärtel
     
  50. Hobodi

    Hobodi

    Joined:
    Dec 30, 2017
    Posts:
    4
    Hello. How can i pick behaviour group via script in OnCollider?
    groupOverrides[m.muscleIndex].props.collisionResistance
    Something like this but m.muscleindex must be different o_O
     
    Last edited: Dec 7, 2018