Search Unity

PuppetMaster - Advanced Character Physics Tool [RELEASED]

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

  1. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    664
    This is the part to send the puppet back to the pool

    Code (JavaScript):
    1.     // send the zombie back to the pool
    2.             transform.position = transform.root.position;
    3.             transform.root.position = thisTransformsPool.position;
    4.             zombiePoolScript.fatZombieStack.Push(this.transform.root);
    5.             transform.root.parent = thisTransformsPool;
    6.     // set the ragdoll State back to alive and its Mode to Kinematic else when the zombie tries to
    7.     // rise out the gound Puppet Master keeps colliding with the floor and take sometime to get up
    8.     // also set the collision resistance back to 100 on the puppet ....
    9.             _puppet.collisionResistance = new Weight(100);
    10.             _puppetMaster.state = RootMotion.Dynamics.PuppetMaster.State.Alive;
    11.             _puppetMaster.mode = RootMotion.Dynamics.PuppetMaster.Mode.Kinematic;
    12.     // _parent is set in Awake() else when deactivating the root it would be the zombie pool
    13.             _parent.SetActive(false);
    And this calls of him

    Code (JavaScript):
    1. function spawnFatZombie ()
    2. {
    3.     spawnTransform = zombiePoolScript.fatZombieStack.Pop();
    4.     spawnTransform.parent = null;
    5.     spawnTransform.position = randomPosition();
    6.     spawnTransform.root.GetChild(0).GetChild(0).gameObject.GetComponent.<RootMotion.Dynamics.BehaviourPuppet>().Reset(randomPosition(), Quaternion.identity);
    7.     spawnTransform.gameObject.SetActive(true);
    8. }
     
  2. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Hey,
    I changed the respawning demo as close to your provided code as I could, still unable to reproduce the issue, the events still work. Please import try the scene included in this package.
     
  3. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    664
    Thanks for doing that, yes yours does work as expected, I'll go through my code and but some debugs in to try and find why mine is not being called, thanks again, great support.

    Kevin.
     
  4. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    664
    @Partel Lang Hi, I found the problem, I have a pool where I give it a number of enemy to pool then it makes that many copies from the enemy prefab then deactivates them until they are needed, my enemy prefab is in a folder and saved active so when the pool has made copies in Awake() it then deactivates them, what i have found is this way when one is called from the pool then SetActive the PuppetMaster seems not to work, I called an enemy from the pool and while it was walking around I set it's State to Dead (in the inspector) and nothing happened, I then put a cube at head hight and as he walked to it his head bent under it as expected, I then changed his Mode to kinematic and he still bent his head as he went under the cube, so PuppetMaster was not responding.

    So then I deactivated the prefab to be pooled saved in the folder, and now when it's called and SetActive PuppetMaster is responding, when I set it's State to Dead he dies, when he walks past the cube and I set the Mode to kinematic he now walks through it, and set the Mode back to active he bends his head under it.

    So when the prefab is saved active, when pooled PuppetMaster does not work, but when saved inactive and pooled PuppetMaster works.
     
    Last edited: Feb 17, 2016
  5. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    664
    @Partel Lang Hi me again ;) when i blow a puppet up most of the time when he lands he goes sliding around the floor
    HERE and HERE

    Here are my settings.

    Screen Shot 2016-02-17 at 10.05.29.png

    And I use this to blow him up.

    Screen Shot 2016-02-17 at 10.08.07.png

    As he hits the floor he just don't want to settle kicking in OnEnd and calling BehaviourPuppet, I've played around with the settings with the same results.
     
  6. PicturesInDark

    PicturesInDark

    Joined:
    Jun 13, 2013
    Posts:
    89
    In my case increasing Get Up Knock out Distance Mlp in Puppet Behaviour to values of 500 made my agent (Tactical/Paragon AI agent) to get up.

    Anyway this is not suffice for me to get my agent not to goes sliding around the floor and then get up ... ;-(
    Even in this movement around the floor the puppet crosses collision walls .-(

    Which controller are you using to move your agent?
     
    Last edited: Feb 17, 2016
  7. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    664
    @PicturesInDark Hi, thanks for the input, I just use the navMesh agent on them.

    As a work around I have a function called from OnEnd from Fall and in that I use

    Code (JavaScript):
    1. puppetMaster.mode = PuppetMaster.State.Dead;
    2. yield WaitForSeconds(1);
    3. puppetMaster.mode = PuppetMaster.State.Alive;
    4.  
    That usually stops them going slide about and they get up.
     
  8. PicturesInDark

    PicturesInDark

    Joined:
    Jun 13, 2013
    Posts:
    89
    Tactical/Paragon AI agent also uses Navmesh. I will try your code till Partel give us a better solution

    Thank you very much
     
  9. PicturesInDark

    PicturesInDark

    Joined:
    Jun 13, 2013
    Posts:
    89
    Hi all
    I have migrated to 0.3 and, with the same settings that with 0.2, I have two problems:
    1. when my puppet falls to the ground, crosses ground and falls below my scene.
    2. When my puppet dies, gets launched to the air too far. SOLVED: Disabling Fix Target Transform

    Griffo, I have probed your work around, a little better but it continues sliding.

    Thanks to all
     
    Last edited: Feb 18, 2016
  10. PicturesInDark

    PicturesInDark

    Joined:
    Jun 13, 2013
    Posts:
    89
    For 1. The only solution I see is making Raycast Layer in Fall Behaviour to Nothing. And even in that case the puppet slides and bounce all the time. It have no sense
    I make Collision Resistance to 3.402823e+38 till Partel make a Tactical/Paragon tutorial
     
  11. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Hey, I have contacted the dev of Tactical Shooter AI to exchange assets so I could put an end to this mess, hold on... :)

    Hey,
    Do the ragdoll bones collide with the ground at all?
    Can you send me a repro or something?

    Pärtel
     
    Tinjaw and Griffo like this.
  12. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    664
    @Partel Lang I'm not using Tactical Shooter AI, just Unity 5's NavMesh ....
     
  13. PicturesInDark

    PicturesInDark

    Joined:
    Jun 13, 2013
    Posts:
    89
    The last discovering is that if I disable Fall Behaviour and I put Max Get Up velocity in Puppet Behaviour at a high value (50), knock out and Get Up is correct. Unfortunatelly when AI agent dies, ragdoll is moved to infinite .... ??

    Partel, I think is something I have done bad, structure merging PM and T/P AI is awfull ;-)

    I prefer wait when you make a tutorial. For me for the moment is suffice PM where agent never falls.

    Thank you very much for you both for your interest.
     
  14. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Hey, sorry I got confused. :)
    Looks a lot like the ragdoll has a zero friction PhysicMaterial so the ragdoll never stops sliding. The materials can be set up in BehaviourPuppet under the "Muscle Group Properties" header.
    Anyway, I have found a bug that stops scripts from updating stuff when PuppetMaster is deactivated while in the middle of switching state or mode. I'm working on a fix, hold on.

    Hey,
    When the ragdoll is moved to infinity and beyond, that usually hints there is something in the character controller raycasting against the ragdoll bones and updating the position of the controller based on that so it kind of gets into this vicious cycle. But I'll take a look at the T/P AI package...

    Cheers,
    Pärtel
     
    Griffo and PicturesInDark like this.
  15. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    OK I'm done, I strongly recommend everyone reading this to import this patch.

    Once you have it, you can feel free to deactivate the entire character hierarchy at any time, set puppetMaster.state to what you need to respawn from and reactivate from another position without having to call BehaviourPuppet.Reset().
    BehaviourPuppet.Reset() you can still use to teleport the puppet. I think I nailed those nasty bugs you were talking about, like sliding across the floor and stuff.

    Cheers,
    Pärtel
     
    PicturesInDark and Griffo like this.
  16. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    664
    Your patch and setting puppet material to normal seem to have fixed the problem, thanks.
     
    Partel-Lang likes this.
  17. PicturesInDark

    PicturesInDark

    Joined:
    Jun 13, 2013
    Posts:
    89
    In my case with this patch I notice no difference. At runtime Tactical/Paragon AI separates controller and ragdoll.
    You have to see that and I will wait till you make a tutorial PM and T/P AI integration.

    Later I will attach a video you to see the hierarchy I have adopted and the behaviour. I cannot send my Project, is 50 GB big.

    Thank you very much for your effort anyway.
     
    Last edited: Feb 19, 2016
  18. montyfi

    montyfi

    Joined:
    Aug 3, 2012
    Posts:
    540
    Got this error after importing:
    Assets/Plugins/RootMotion/PuppetMaster/_Integration/Final-IK/Behaviours/Biped/BehaviourBipedBalanceFBBIK.cs(8,30): error CS0534: `RootMotion.Dynamics.BehaviourBipedBalanceFBBIK' does not implement inherited abstract member `RootMotion.Dynamics.BehaviourBase.OnReactivate()'
     
  19. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Delete the _Integrations/Final IK folder and reimport the Final-IK bridge, the updated one was in the patch.

    Cheers,
    Pärtel
     
  20. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    As a owner/user of both assets, I greatly appreciate this effort.
     
    Partel-Lang likes this.
  21. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Here's a great implementation of PuppetMaster in a mobile snowboard, freeski and skateboard game:

    MyTP 3

    Thanks for sharing, Randerline, now I have something to do next time I'm on a plane! :)

    Pärtel
     
  22. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    664
    @Partel Lang Hi, I just added a rag doll and PM to THIS model and when I press play the rag doll drops off the model?

    The model has nothing attached or running on it, and all the PM settings are as new.

    Any idea why it would do this?

    Thanks.
     
  23. atmosfearteam

    atmosfearteam

    Joined:
    Nov 10, 2015
    Posts:
    42
    @Partel Lang I was just trying out Puppet Master for the first time. Looks pretty great. Thanks for the great asset!

    But I have an issue. With the character I'm using (The male Morph3D character from the asset store) the ragdoll doesn't match it exactly. I adjusted some things and now everything matches pretty good except the forearms. If I try to move the forearm collider objects, that are under the PuppetMaster object, to the right place and then hit play I get this message in the console:

    And if I use the "Fix Muscle Positions" option in the menu it makes it so the forearms are too far forward on the Z axis. Then I try to move them back to where they should be and I get the error again, so it's a never-ending cycle.

    Is there any way to fix this?

    Thanks!
     
  24. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Is there an error/warning in the console? Looks like PM has not initiated for some reason. Check puppetMaster.initiated in play mode and see if returns true or false. Or just send me the rig and I'll take a look myself.

    Hey, thanks for the purchase!
    You should add the RagdollEditor component on that character and use it to move the colliders. You should not move the ragdoll gameobjects directly, just the colliders. Also switch to edit joints and see if the joint limits were set up correctly.

    Cheers,
    Pärtel
     
  25. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    664
    It's saying puppetMaster.initiated is false
     
  26. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Then it must give you a warning/error message. Play the scene and check the Console to see if there are any messages from PuppetMaster there. There should be one of the error messages you see in PuppetMasterValidation.cs.
     
  27. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    664
    Is this the one?

    Screen Shot 2016-02-23 at 10.33.04.png
     
  28. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Yes, just make sure the position/rotation of the animated character is the same as the PuppetMaster gameobject's in the Editor
     
  29. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    664
    Yes they match, I send you the rig now by email.
     
  30. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Maybe there's something moving the character already in Awake before PuppetMaster initiates?

    Because the error is called like that:
    Code (CSharp):
    1. if (targetRoot.position != transform.position) {
    2.                 // Log error, stop initiation
    3.             }
    So the character must have moved before that point..
     
    Last edited: Feb 23, 2016
  31. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    664
    Your a star .. I just found

    Code (JavaScript):
    1. transform.localPosition += Vector3(0,-4,0);
    That move him under the ground in Awake() before he rises from the ground.

    Thank you.
     
    Partel-Lang likes this.
  32. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Great! If you move the entire rig, it should be ok :)
     
  33. eagleeyez

    eagleeyez

    Joined:
    Mar 21, 2013
    Posts:
    350
    Hi, bought Puppet Master today, followed your Very good tutorial third person controller, by the way (keep this up with tutorials). Then I realized TPC gives a puppet script download and say now it is easier than in you video. Sadly nothing works. I followed everything exactly but still when I press play Alexis or any other I try also your dummy , just keep bouncing up and down in a running mode on the spot.

    Please help, please how do I get this working with Thirdperson controller from Opsive?

    Written step by step please or a new tutorial.
     
  34. DMeville

    DMeville

    Joined:
    May 5, 2013
    Posts:
    400
    Hey Partel,

    Quick question - any tips on how to integrate Chronos (https://www.assetstore.unity3d.com/en/#!/content/31225) with Puppetmaster for some sweet slow-mo ragdolls?

    I got it working *mostly* by just dropping in Timeline components on all the rigidbodies, as well as changing some uses of Time.deltaTime to use Chronos, however I can't seem to get the ragdolls to "loosen" up when going slowmo (they stay pretty rigid at slow timescales).

    I'd guess this has something to do with the muscles still applying the same forces at the slowed down scale, but I couldn't figure out how to change this. I more than likely just overlooked something though.
     
  35. atmosfearteam

    atmosfearteam

    Joined:
    Nov 10, 2015
    Posts:
    42
    @Partel Lang Thanks for your last reply. I got it working now. :)

    I was having one more issue though. I was following your video tutorial here and most of it is working (the body ragdolls when I hit certain objects) but I'm getting an error spammed in the console shortly after I do a collision and the character never gets back up. Here is the error:
    I do in fact have a "FallBlend" animator parameter on my character's animator.

    What I'm doing wrong will probably end up being something really obvious :p, but as of now I can't seem to figure it out.

    Thanks for your help!
     
  36. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Hey, thanks for the purchase!

    It probably just needs updating to PuppetMaster 0.3. I was going to take a look but I can't download the PuppetController since I dont have an invoice number (we exchanged assets) I asked Opsive for it so I hope they reply soon, then I'll get back to you on this.

    Hey,
    Does Chronos change fixed time step?
    If it does, then yes, with more fixed steps, the muscles will become stronger. That's just how that works in PhysX.
    Maybe something like
    Code (CSharp):
    1. puppetMaster.muscleWeight = Time.timeScale;
    would help.

    That line can cause a NullReferenceException only if PuppetMaster.targetAnimator is null. Where exactly do you have your Animator component?

    Cheers,
    Pärtel
     
  37. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Hey, I got a reply from Opsive. He said he tested PuppetController with PuppetMaster 0.3 and it was working as expected.. He said that maybe you had an old version of TPC or PuppetMaster, so let me know you have the latest, but still have problems.
     
    Tinjaw likes this.
  38. eagleeyez

    eagleeyez

    Joined:
    Mar 21, 2013
    Posts:
    350
    Ok, I don’t really know now. I am trying to get a model working with TPC and Puppet Master with the integration Plug-in. No matter what model I use they kick their legs back and forth backwards constantly.

    I have added the puppet controller from Third person controller to puppet master and set the behaviors. I have done about everything now, so please help. The demo scene works perfectly with the pilot model, but use another model and it goes crazy.

    Just a simple example of how to set up a model with TPC and Puppet Master would be cool.

    BTW. I have been trying ICE Creature control: with this and I can see this is a must integrate product also playmaker would be cool for complete integration with all products.

    I can also make a video of this problem if necessary.
     
  39. eagleeyez

    eagleeyez

    Joined:
    Mar 21, 2013
    Posts:
    350
    I delleted my last post as :

    Sorry I got confused with Opsive and ICE and Motion controller

    Opsive still not working, ICE could work if added to integration and Motion Controller not good.
     
  40. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Hey, I made a step-by-step for you.
    I think the legs kicking back and forth was because of the CharacterIK component that is raycasting against the ragdoll bones. Unfortunately Opsive doesn't provide a layer mask for us to change that so I just disabled it for now.
    If you need that feature, it should be possible to get the source code, add a public LayerMask layers; and just add that to the end of all Raycast/SphereCast calls.

    Anyway, here's the list:
    1. Drag your character fbx to the demo scene in the integration package
    2. Use TPC CharacterBuilder on that character, uncheck “Add Ragdoll"
    3. Change AnimatorController to the one provided in the integration package (“Controller”)
    4. Disable CharacterIK component on the character, it is raycasting against the ragdoll colliders
    5. Use BipedRagdollCreator to create a ragdoll
    6. Add PuppetMaster to the character, click on “Set Up PuppetMaster”. You will probably get some errors aboud components not being deleted because other components depend on them. Ignore those errors and manually delete all components except PuppetMaster from the PuppetMaster gameobject.
    7. Go to Main Camera and replace CameraController Target
    8. Copy behaviours (Fall, Puppet) from the Pilot to you own character
    9. Add PuppetController to the PuppetMaster gameobject, assign it’s properties
    10. Go to BehaviourPuppet, reassign event target gameobjects and functions for the “On Loose Balance” and “On Regain Balance” events.

    If still no luck, please send me a video or a package with the scene or something.
    Cheers,
    Pärtel
     
  41. eagleeyez

    eagleeyez

    Joined:
    Mar 21, 2013
    Posts:
    350


    Thanks, that nailed it. After the puppet master has finished its job, then delete the collider and rigidbody in that component. It was the IK causing the problems.

    Thanks

    And now it would be cool if you could get together with ICE Creature control, as this is a must to integrate with Puppet master and then both ICE and PM will then fit like a pair of gloves should.
     
    montyfi likes this.
  42. eagleeyez

    eagleeyez

    Joined:
    Mar 21, 2013
    Posts:
    350
    Ok, there are stil problems. I will make a video tomorrow.
     
  43. atmosfearteam

    atmosfearteam

    Joined:
    Nov 10, 2015
    Posts:
    42
    Oh, I did have an issue with my animator. I was able to fix it and now it seems to be working. Thanks for pointing me in the right direction. :)

    I had one more question... Would there be any issue with moving the main Rigidbody, Capsule Collider, etc from the sub-object that contains the player/mesh to the new root object that PuppetMaster creates? It seems that by default PuppetMaster takes your player object, along with all its components, and moves it under a root object. I'm wondering if there would be any issue with taking all the components off the player object (that is now a sub-object) and move them onto the new root object?

    So like, this is how it is by default:
    Code (csharp):
    1. - Root (Has No Components)
    2.    - Mesh
    3.      - Rigidbody
    4.      - Capsule Collider
    5.      - Character Control Scripts
    6.    - Behaviours
    7.      - Fall
    8.      - Puppet
    9.    - PuppetMaster
    10.      - Lots of Colliders for the Puppet...
    And I'm talking about having it like this:
    Code (csharp):
    1. - Root (Now has Rigidbody, Capsule Collider, Character Control Scripts, etc.)
    2.    - Mesh (Now has no components, except maybe for Animator)
    3.    - Behaviours
    4.      - Fall
    5.      - Puppet
    6.    - PuppetMaster
    7.      - Lots of Colliders for the Puppet...
    So is that possible? Would any changes be needed to allow that? Or would there be too many issues?


    Thanks for all the help! :)
     
  44. eagleeyez

    eagleeyez

    Joined:
    Mar 21, 2013
    Posts:
    350
    I have removed the video from this post as my problem was that I was forgetting to link the events as described in point 10 from Partel Lang. I will make another video soon with Puppet Master, TPC and ICE

    10. Go to BehaviourPuppet, reassign event target gameobjects and functions for the “On Loose Balance” and “On Regain Balance” events.

    He actually shows you this in his video TPC integration. I somehow had skipped that important part.
     
    Last edited: Feb 28, 2016
  45. gaiomed

    gaiomed

    Joined:
    May 5, 2013
    Posts:
    44
    Hi,

    I am working on dead puppets floating in water, for that I want to connect 4 targets to hands and feet and move them around with some perlin noise. This part works fine but when the distance between the limbs get to big, the puppet starts jumping around as the physics seems to be torn apart but is constraint. My question is it possible to constrain the maximum extends easily so that this jumping and out of control physics does not happen?
    I can use the bounding box of the bodies mesh to get some control but I wonder if there is an easy way to constrain tearing forces?
     
  46. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Hey,
    The problem with this would be that when you move the Root of everything, that would also move the ragdoll. You see when the puppet starts getting up, it will have to move the character to where the ragdoll is, but if the ragdoll was parented to the character, it would be moved as well, which is not what we want.

    Hey,
    It could be worth it to increase Solver Iteration Count, that makes the joints more stable. And/Or enable Projection on the joints, that just makes sure they don't separate.
    But if you need to simulate water, you might want to do it by using forces instead of constraints. Basically just add an upward force to each Rigidbody and add some sort of sine function to modify that force based on rigidbody position to simulate waves or currents.

    I put it down on my list, but its a quite long list already, so I don't know when that will happen. I can't cover all the AI/character controller packages out there anyhow :)

    Cheers,
    Pärtel
     
    montyfi likes this.
  47. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Opsive said they added a layermask to CharacterIK for their next version. :)
     
    Tinjaw likes this.
  48. montyfi

    montyfi

    Joined:
    Aug 3, 2012
    Posts:
    540
    Second for ICE, probably the best system for animal/npc AI in store.
     
    TonanBora likes this.
  49. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,922
    Noted, thanks for the input :)
     
    TonanBora and montyfi like this.
  50. designico

    designico

    Joined:
    Apr 2, 2013
    Posts:
    9
    Hey @Partel Lang I'm about to buy your asset, but I have to ask a question before invest my money on it.

    I want to make a wave shooter game with biped robots (T800 like). Very important is the possibility to literally push the enemy back by shooting on him. This of course should look very natural (thats why I'm here). And an other importent thing is that the hit zones animations should look realistic.. I think all this is possible with Puppet Master or do I have to buy Final IK as well? If yes why? And do you have any advice how to achieve all this (I didn't worked with human animation till now).