Search Unity

PuppetMaster - Advanced Character Physics Tool [RELEASED]

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

  1. Ron-Wilson

    Ron-Wilson

    Joined:
    Oct 2, 2012
    Posts:
    37
    one of my ideas is make a few duplicate characters using puppet master reduce their scale and apply AI using ICE and have them pursue a full size character also using puppet master without any killing (non violent) maybe a club in the hands of the main player to knock the reduced sized characters off their feet as she runs through a cave or maze ......sort of a tag type game.........Tomb Raider style without any killing !
    Thanks again Partel
     
  2. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    416
    Partel,

    Thanks for posting the OnPostMuscleCollision code snippet. It's working very well. :)

    I have a question about physics layers in regards to the OnPostMuscleCollision Event. I was surprised to find that the OnPostMuscleCollision event returns collisions with all physics layers. I just assumed collisions would be limited to the layers you designated as your Collision layers in BehaviourPuppet. I think it's ok either way because it's easy enough to limit my animation calls in code by checking if (m.collision.gameobject.layer == whateverLayer).

    I'm just wondering if that is by design and is there a more efficient method for limiting the physics layers that return collisions in those behaviourPuppet (BehaviourBase) collision events.

    Thanks
    Allan
     
  3. Partel-Lang

    Partel-Lang

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

    You can release the pin weights of the upper body muscles to make him wobble around a bit. Maybe use FBBIK effector offsets or the Amplifier to change the look of the animation. Reduce collision resistance to make him fall over more easily. But there's no GTA/RDR drunk walk behaviour.

    Hey, have you seen the "Melee" demo? Its all about beating others with clubs, quite violent I'm afraid. :)

    Well ahead of you there mate, that's what the BehaivourPuppet.OnCollisionImpulse delegate is there for:

    Code (CSharp):
    1. public BehaviourPuppet behaviourPuppet;
    2.  
    3.         void Awake() {
    4.             behaviourPuppet.OnCollisionImpulse += OnCollisionImpulse;
    5.         }
    6.      
    7.         void OnCollisionImpulse(MuscleCollision m, float impulse) {
    8.             // float impulse is not Collision.impulse, but the final calculated blow to the puppet, accounting for collision resistance and all that.
    9.         }
    Cheers,
    Pärtel
     
    umcherrel likes this.
  4. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    416
    Partel,

    Oh man, that's really nice!! Yes I see.....and that's where the BehaviourPuppetDamage partial class comes into the picture....you filter by layer, collisionThreshold and get the impulse. I've only recently learned about partial classes. It seems like a nice way to compartmentalize code into smaller chunks. It does make it a little more difficult to follow the flow of the code because the class names in the project don't match the actual class name. But now that I am aware of their use, it should be easier follow.

    You do a great job of thinking ahead when you develop these tools. :)

    Using the OnCollisionImpulse delegate should provide better performance because you are filtering out Physics layered objects as defined by the user in BehaviourPuppet using LayerMaskExtensions prior to the delegate/event being called by my code.

    I also see that there is a nice example of using this delegate/event in FXCollisionBlood.cs if anyone wants to check out how this useful delegate is used in the demos. This also reminded me that I need to Destroy those Events.

    Code (CSharp):
    1. void OnDestroy() {
    2.             if (puppet != null) puppet.OnCollisionImpulse -= OnCollisionImpulse;
    3.         }
    Good stuff.

    Allan
     
    Partel-Lang likes this.
  5. Ron-Wilson

    Ron-Wilson

    Joined:
    Oct 2, 2012
    Posts:
    37
    Yes I have see Melee...........great demo and am looking at it now , I took my Prefab of my Character and set her up to be struck down in the Melee demo already and am now studying it to make her master of the club.................that's what I want to do as a first step then will convert other models to chase
    Thanks Partel for the demos without them I would be way behind.....not easy for an almost 70 old man to grasp !
    Ron
     
  6. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hey, actually just today I finished a script that lets you replace the character model both in "Puppet Extended" and "Melee" demo scenes with just a single click. Write to me support@root-motion.com and I give you a link to the latest WIP version of 0.3.

    Hey, you're a role model for me. There's no retirement for Asset Store publishers :)
     
  7. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hey everyone, a new tutorial, this time it's about Final-IK's AimIK. :)

     
    montyfi and Mister-D like this.
  8. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    416
    Partel,

    Something I noticed while working on Events in BehaviourPuppet.

    On Regain Balance is called immediately when you hit play. I was going to run an animation after the character fell and regained his balance using this event. I set it up and immediately upon pressing play, that animation was executed. I figured it had something to do with my character setup so I tested it in your PuppetExtended scene and sure enough it is called at the beginning of play. To do a quick test I just added a Unity Event to the On Regain Balance Event in the Events section of BehaviourPuppet in the inspector. I dragged the pilot Character Controller to the Unity Event and then made a public method in CharacterThirdPerson.cs with a Debug.Log and selected that method in the inspector.
    The Debug.Log is executed upon pressing play.

    This seems like a bug unless the On Regain Balance Event is meant to run at the beginning of play.

    Allan
     
  9. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    416
    Question about the Fix Target Transform option on PuppetMaster;

    In your performance recommendations in the docs, you recommend leaving it unchecked. In order to use props, as far as I can tell, you have to have it checked. Otherwise your props will get knocked out of rotation by any collision. And once a prop is knocked out of rotation, there's no way to fix them during gameplay unless you setup some sort of reset at some designated timeframe within your code or do a reset upon collision.

    Looking at the code in PuppetMaster, it looks like the fixTargetTransforms is an all or nothing type of thing meaning it fixes every muscle on the character every update loop. I'm just wondering if an option to only fix the target transform of the attached props might be something that can be added.

    Couple of thoughts:
    - I'm not entirely sure what the performance hit is with this feature but since I'm developing for mobile, I try to keep these things in mind. Resetting every muscle transform every update loop combined with ongoing collision checks sounds like a lot but it's all relative to whatever else you need in your game.
    - Other than its effect on props, I don't really know what else this feature effects. The tooltip says "Use this only if the target contains unanimated bones." I don't know what that means. Are props unanimated bones?
    - Perhaps have 2 options: Fix All Target Transforms and Fix Prop Target Transforms
    - Would leaving Fix Target Transforms unchecked and then fixing the prop transforms only upon collision be an option?

    Allan
     
  10. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    416
    Sorry for all of the questions, I feel like I keep running into things I don't fully understand. :)

    In BehaviourPuppet, the option Map Only On Contact is very cool. It means the character mesh maps 100% to the animation until a collision occurs at which time the character mesh will map to the Ragdoll for a short timeframe and then snap back to the animation. (So you get the accuracy of the animation and the goofy ragdoll effect) Nice!

    Is it possible to control how long the character mesh stays mapped to the ragdoll after the collision? I see you have Mapping Blend Speed. But that appears to be an actual blend time as opposed to a length of time.

    Thanks
    Allan
     
  11. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    416
    Hey guys,

    Just wanted to share some fun I had with my Ragdoll. Playing with Props and Ragdoll Collisions in PuppetMaster.



    Allan
     
    kurotatsu, Mikael-H, MIK3K and 2 others like this.
  12. Alfonso_CJ

    Alfonso_CJ

    Joined:
    Nov 19, 2015
    Posts:
    35
  13. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hey, thanks, it's a known bug that has already been fixed. I plan to submit 0.3 by the end of this week. If you wish to fix it yourself now open BehaviourPuppet, add somewhere:

    Code (CSharp):
    1. private bool eventsEnabled;
    then as the last line in protected override void OnInitiate() add:

    Code (CSharp):
    1. eventsEnabled = true;
    Then open BehaviourPuppetStateSwitching.cs, in public void SetState() replace

    Code (CSharp):
    1. onRegainBalance.Trigger(puppetMaster);
    2. if (onRegainBalance.switchBehaviour) return;
    with

    Code (CSharp):
    1. if (eventsEnabled) {
    2. onRegainBalance.Trigger(puppetMaster);
    3. if (onRegainBalance.switchBehaviour) return;
    4. }
    The Fix Transforms thing is there because with PM, the animated character (Target) will end up mapped to the ragdoll. If there's now animation overwriting that pose next frame, PM will start following the pose it last mapped the Target to, ending up in a sort of infinite loop. Sometimes it's the case that some bones have keys in the animation and some don't and it's cheaper to just fix them all instead of running checks if they have moved each time.
    So "Fix Transforms" moves the Target bones to their default local position/rotation just in case the animation doesn't.

    But you got a valid point there, I'll see if that can be implemented, in meanwhile just leave the toggle on. :)

    The whole activation and map only on contact thing has been changed in 0.3. It's now like this:

    Code (CSharp):
    1. [System.Serializable]
    2.         public enum NormalMode {
    3.             Active,
    4.             Unmapped,
    5.             Kinematic
    6.         }
    Active is when the puppet is active and mapped at all times, Unmapped is what map only on contact used to be and Kinematic switches from active to kinematic and back. With Unmapped, it will blend the mapping out as soon as all pinning has been fully restored, there's really no need to keep it mapped any longer.

    Looking great :), combining reaction animation with PM is something I've been wanting to experiment with for a long time, just haven't reached there yet. But I anticipate it will be a powerful thing.
    Only problem is that when the collision happens, it's a bit late to trigger the animation so they feel a out of sync.
    Maybe adding a larger trigger collider around the character that would register any incoming projectiles and predict a collision and trigger the animation in advance.. ;)

    Anyway, thanks a lot for all your feedback, it is most valuable, I wish I had you in the private beta testing! :)

    Hey, that's a great idea I think! :)
    Looks like you need to check "Internal Collisions" and "Angular Limits" in the PM, I think the feet were crossing through each other.

    Cheers,
    Pärtel
     
    Last edited: Jan 11, 2016
  14. xalsVR

    xalsVR

    Joined:
    Jan 2, 2014
    Posts:
    16
    Hi Pärtel,

    We love your assets. We use FinalIK and PuppetMaster, but in this case we have a question about PuppetMaster. In the "Hanging" demo we can read:
    Do you have any demo for this? We should update a Full Body Biped IK after the PuppetMaster Update or what? We need light upon this, please.

    Thanks!
     
  15. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hey, thanks!

    Have you downloaded the PuppetMaster Final-IK Bridge?
    In that package there is a scene "IK After Physics", where FBBIK is being applied on top of PuppetMaster's mapping to ragdoll.

    Cheers,
    Pärtel
     
  16. montyfi

    montyfi

    Joined:
    Aug 3, 2012
    Posts:
    548
    Almost forgot about that one. Could you add it as part of Puppet Master asset? Maybe as unity package inside. Then it wont interfere and always be easily accessible for everyone who owns Final IK
     
  17. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    A unitypackage inside.. why didn't I think of it. Thanks, will do! :)

    Pärtel
     
    hippocoder, hopeful and montyfi like this.
  18. xalsVR

    xalsVR

    Joined:
    Jan 2, 2014
    Posts:
    16
    Ops, I forgot about it. I'm gonna try right now! I'm totally agree with @montyfi about add it to PuppetMaster.
    Thanks
     
  19. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    517
    Partel-Lang, MIK3K, Mikael-H and 2 others like this.
  20. Alfonso_CJ

    Alfonso_CJ

    Joined:
    Nov 19, 2015
    Posts:
    35
    Der_Kevin likes this.
  21. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
  22. dreasgrech

    dreasgrech

    Joined:
    Feb 9, 2013
    Posts:
    205
    @Partel Lang

    In BipedRagdollCreator.Create(BipedRagdollReferences, Options), you are calling ClearAll(r.root) to clean all the children GameObjects from the root.

    Is there any reason why you're not calling ClearBipedRagdoll(r) instead of ClearAll(r.root), so that the method only cleans the GameObjects that are directly related with the ragdoll?

    The reason I ask is because I have other GameObjects in my character model which contain trigger colliders that are used as melee hitboxes, and I don't want that method to remove my colliders when I create the ragdoll at runtime.
     
  23. montyfi

    montyfi

    Joined:
    Aug 3, 2012
    Posts:
    548
    Is this out already?
     
  24. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hey,
    I'm calling ClearAll because if the references change, the ragdoll components will not be cleared from the bone that was reassigned. But if you wish to keep trigger colliders, you can go to line 77 in RagdollCreator.cs, where there is
    Code (CSharp):
    1. protected static void ClearTransform(Transform transform)
    and change the code inside to:
    Code (CSharp):
    1. protected static void ClearTransform(Transform transform) {
    2.             if (transform == null) return;
    3.  
    4.             var collider = transform.GetComponent<Collider>();
    5.             if (collider != null && !collider.isTrigger) GameObject.DestroyImmediate(collider);
    6.  
    7.             var joint = transform.GetComponent<Joint>();
    8.             if (joint != null) GameObject.DestroyImmediate(joint);
    9.  
    10.             var rigidbody = transform.GetComponent<Rigidbody>();
    11.             if (rigidbody != null) GameObject.DestroyImmediate(rigidbody);
    12.         }
    I'll add that adjustment to the next version.

    Hey, it has already been implemented for the next version but it's not released yet. It's a single click procedure now, if you are in a rush, send me your invoice no and I'll give you a link.

    Cheers,
    Pärtel
     
    dreasgrech likes this.
  25. montyfi

    montyfi

    Joined:
    Aug 3, 2012
    Posts:
    548
    No rush at all, followed your instructions yesterday and was able to setup my own character in minutes. Just thought it will be hard to find on forum over time :)
    Thank you!
     
  26. montyfi

    montyfi

    Joined:
    Aug 3, 2012
    Posts:
    548
    @Partel Lang, oh, a small question, when character go into ragdoll - your camera stops its movement and then catch up. Could you please advice how to change that? I want the camera not to stop, but slowed. Where should I look?
     
  27. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hey, that too has been changed for PM 0.3. But you can just go to the camera, change the "Target" of the camera controller script to one of the bones in the ragdoll hierarchy. I just need a day or two to get 0.3 submitted, its a major improvement with 3 pages of release notes so far. :)

    Cheers,
    Pärtel
     
    GrimDjim, florianbepunkt and montyfi like this.
  28. florianbepunkt

    florianbepunkt

    Joined:
    Nov 28, 2015
    Posts:
    45
    Has the Motion Controller integration made it into the three pages? Motion Controller, Final IK & Puppet Master is a really ppwerful combo.
     
  29. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Actually, Im working on it as we speak. Just about to wrap it up and send to Tim to see if he has any thoughts about it. :)
     
    GrimDjim, Licarell and florianbepunkt like this.
  30. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hi all!

    I just submitted PuppetMaster 0.3 and Final-IK 1.3 for review.
    0.3 is a major step forward for PuppetMaster, please read the release notes below, especially the Upgrade Guide part.

    My favourite new feature is something that should have been there from the start - PuppetMaster.state, that you can use to very easily switch between Alive, Dead and Frozen states and that also works with BehaviourPuppet and BehaviourFall, regardless of which mode you are in. Frozen means the ragdoll will be deactivated once it has come to stop in the dead state. See the "Killing" demo scene.
    Screen Shot 2016-01-20 at 13.52.49.png

    There are also quite significant performance improvements to BehaviourPuppet, added the Final-IK, UMA2, Ootii's Motion Controller integration packages to "Plugins/RootMotion/PuppetMaster/_Integration". There are also a couple of new demo scenes. See the release notes below for the complete list:

    Version 0.3

    Upgrade Guide

    MAKE A BACKUP! Open a new scene, delete the previous version and reimport.
    1. If you were using BehaviourPuppet.canActivate, you should set BehaviourPuppet.normalMode to “Kinematic”.
    2. If you were using BehaviourPuppet.mapOnlyOnContact, you should set BehaviourPuppet.normalMode to “Unmapped”.
    3. To get rid of multiple expensive SendMessage/ BroadcastMessage calls per frame, OnPuppetMasterRead, OnPuppetMasterWrite and OnPuppetMasterFixTransforms will not be called anymore. Use PuppetMaster.OnRead, PuppetMaster.OnWrite and PuppetMaster.OnFixTransforms delegates instead. See the IKBeforePhysics.cs and IKAfterPhysics.cs for reference. If you add any IK components to the Target hierarchy in runtime after PuppetMaster has initiated, you need to add them manually to the PuppetMaster.solvers generic list.
    4. If you are using Final-IK, wait until Final-IK 1.3 becomes available (will be updated simultaneously) and import the latest Final-IK Bridge from the unitypackage in Plugins/RootMotion/PuppetMaster/_Integration.
    5. If your puppet starts sliding when getting up, set “Get Up Offset Prone” and “Get Up Offset Supine” to Vector3.zero in BehaviourPuppet.
    6. If you have used the CharacterMeleeDemo character controller, change UserControlPuppet to UserControlMelee and assign the “Hit Key”.

    Improvements

    1. Created the first version of the bridge between PM and UMA2. Import to a project with both PuppetMaster and UMA2.
    2. Added a warning if Target position doesn’t match with the PuppetMaster’s position at initiation.
    3. Added a warning if any of the muscle joint positions don’t match with their target’s positions (right-click on the PuppetMaster component’s header and select “Fix Muscle Positions” to fix this issue).
    4. Added a warning if mass variation between the ragdoll Rigidbodies is greater than 100.
    5. Added a warning if one of the “Ground Layers” is included in the “Collision Layers” of BehaviourPuppet.
    6. Added a warning if one of the ragdoll bones is on the same layer as the character controller.
    7. Added a warning if one of the ragdoll bones is on a layer that is not set to ignore the character controller layer.
    8. Improved blending from ragdoll to getting up. Puppets can now get up with much less BehaviourPuppet.getUpKnockOutDistanceMlp, increasing collision-reaction fidelity while getting up.
    9. Considerably improved the performance and stability of BehaviourPuppet.
    10. Named the “Muscle Group Overrides” in BehaviourPuppet’s Editor so the right one could be more easily found.
    11. New larger header attributes (easier to read, especially when dealing with edited prefabs that have some fields in bold).
    12. BehavirouPuppet will activate itself on initiation only if it is enabled at that time. That enables you to start from another behaviour such as Fall when you disable BehavirourPuppet in the Editor.
    13. Added “Max Collisions” value for BehaviourPuppet as an optimisation. The behaviour will not process more collisions than this in each physics step.
    14. Added the “LookAtIK” demo to the Final-IK Bridge.
    15. Added the “AimIK” demo to the Final-IK Bridge.
    16. The demo character models can now be replaced with any Humanoid character in the scene, fbx or ragdoll simply by going to the “Character Controller” gameobject, assigning a “Replace Character Model” and clicking on “Replace”.
    17. Improved puppet-puppet head-on collision handling, no more bouncing back from the standing bot.
    18. Added the “Creating Ragdolls In Runtime” demo scene and script.
    19. BehaviourFall now keeps the Target close to the ragdoll. That will help with camera scripts and SkinnedMeshRenderer culling.
    20. Added PuppetMaster.state to make it as easy as possible to switch between Alive, Dead and Frozen states. Frozen means all physics coponents will be deactivated when the puppet is killed and rigidbody velocities below a threshold and unnecessary calculations skipped.
    21. Added the “Killing” demo scene.
    22. Added an interpolated puppet example to the “Puppet Extended” demo scene.
    23. Added warnings to PuppetMaster when Animator.cullingMode is not “Always Animate” or SkinnedMeshRenderer “Update When Offscreen” is false.
    24. Simplified the Prop component.
    25. Extended the Melee demo, added walls, collision objects and the Teddy to demonstrate bumping into larger and heavier characters.
    26. Added the Final-IK Bridge, UMA2, Ootii’s Motion Controller v2 and others to “Plugins/RootMotion/PuppetMaster/_Integration” as unitypackages.
    Fixes

    1. BipedRagdollCreator now forces joint anchors to Vector3.zero.
    2. Behaviours will not fail when UMA replaces the Animator in runtime.
    3. Removed JointDriveMode warnings from Unity 5.3 and later.
    4. Fixed Grounding the Target when getting up.
    5. Fixed a bug that twitched the puppet when “Can Activate” and “Deactivate Automatically” were selected.
    6. Fixed a Null Reference Exception when a Booster was created in runtime.
    7. Fixed negative collider sizes created by BipedRagdollCreator that were a problem with Unity 5.4.0B1.
    8. BipedRagdollCreator will not let itself to be added on any other gameobject but the root of the character.
    9. Fixed a bug with PropRoot and assigning currentProp at Start();
    10. PuppetMaster will notify you if you try to run it in Unity 5.1 (requires at least 5.2.2).
    11. Fixed a bug with the Target not mapped to the ragdoll each frame when ragdoll bones were set to interpolate.
    12. FixTransforms will work for Props even when PuppetMaster.fixTransforms == false, because they are most likely always unanimated.
    13. Removed PuppetMaster.broadcastGroundCollisions.
    14. Muscles with Pin Weight set to 0 will also unpin the puppet when they get too far.
    15. Disabled a bug with internal collisions not being ingored when internalCollisions == false and switching from Disabled to Active or Kinematic mode.
    16. Setting PuppetMaster.mode to Disabled or Kinematic will only execute when the behaviours allow it. That means you will be able to safely Disable a puppet based on distance to another puppet without the puppet getting disabled while in Fall behaviour or getting up.
    17. Fixed BehaviourPuppet.unpinnedMuscleWeight not working when BehaviourFall was also used.
    18. Made BipedRagdollCreator work when “Optimize Game Objects” used.

    Changes

    1. Changed BehaviourPuppet.canActivate and BehaviourPuppet.deactivateAutomatically to a single enum: BehaviourPuppet.normalMode.
    2. To get rid of multiple expensive SendMessage/ BroadcastMessage calls per frame, OnPuppetMasterRead, OnPuppetMasterWrite and OnPuppetMasterFixTransforms will not be called anymore. Use PuppetMaster.OnRead, PuppetMaster.OnWrite and PuppetMaster.OnFixTransforms delegates instead. See the IKBeforePhysics.cs and IKAfterPhysics.cs for reference. If you add any IK components to the Target hierarchy in runtime after PuppetMaster has initiated, you need to add them manually to the PuppetMaster.solvers generic list.
    3. Moved SolverManager to RootMotion namespace, allowing it to be used by other assets besides Final IK.


     
  31. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    montyfi likes this.
  32. montyfi

    montyfi

    Joined:
    Aug 3, 2012
    Posts:
    548
    Beautiful! But from the demo I cannot see any difference between green and black objects. For me they behave the same as without puppet master. What should I look for?
     
  33. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    The green walls collide with both the character controller and the ragdoll colliders so it's just the character controller capsule that is keeping the ragdoll from smashing into the wall. It's more evident if you grab that blue stick and try to hit the green wall with it or run into it. :)
     
    montyfi likes this.
  34. montyfi

    montyfi

    Joined:
    Aug 3, 2012
    Posts:
    548
    Oh, I see, pretty cool!
     
  35. montyfi

    montyfi

    Joined:
    Aug 3, 2012
    Posts:
    548
    I'm making holes in terrain using RTP, it does this: Physics.IgnoreCollision(_collider, terrainColliders, true);
    But that's probably the wrong way for your character controller. What would be the correct way to make character fall in terrain hole?
     
  36. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hi,
    Physics.IgnoreCollision is not a very good thing in general, it needs to be called again each time any of those colliders are disabled or deactivated so it might create some bugs for you that are difficult to trace.
    It's much better to use the Project Settings/Physics/Layer Collision Matrix and disable collisions between layers instead.

    But if you need your puppet to fall though something, just make sure the character controller nor the ragdoll bones collide with it.

    Pärtel
     
  37. montyfi

    montyfi

    Joined:
    Aug 3, 2012
    Posts:
    548
    That was my question, how to do it runtime, ontriggerenter :)
    I would need to change walkable layers in PuppetMaster perhaps? Can I do it runtime?
     
  38. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Code (CSharp):
    1. Physics.IgnoreLayerCollision(puppetMaster.targetRoot.gameObject.layer, terrainLayer);
    2. Physics.IgnoreLayerCollision(puppetMaster.gameObject.layer, terrainLayer);
     
    montyfi likes this.
  39. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    416
    Partel,

    I'm still on PuppetMaster .2.

    When I press Play, for the 1st frame or so, if I have the game paused, the PuppetMaster appears at vector3(0, 0, 0) and then quickly snaps to the position of the character controller and root gameobject. This has been this way since I first created my PuppetMaster/Ragdoll and since it does not occur when I relocate the pilot in Puppet Extended and press play, I have to assume it's because I created my ragdoll/puppetmaster setup with my character not at vector3(0f, 0f, 0f). And now the starting position of the PuppetMaster is out of whack.

    Is this something .3 will fix or is there something I can do to fix it manually now.

    Thanks
    Allan
     
  40. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hey,
    So did I understand you right, your ragdoll's position matches with the animated character, just the PuppetMaster gameobject is somewhere else?
    If this is the case, just unparent the ragdoll from the PuppetMaster for a moment, move the PuppetMaster gameobject to the right place and then parent the ragdoll back to it.
    I'll take a look at how this could be improved in the future..

    Cheers,
    Pärtel
     
  41. montyfi

    montyfi

    Joined:
    Aug 3, 2012
    Posts:
    548
    I had to set PuppetMaster mode to kinematic at that point as well, otherwise it is working, thanks!
    Now just need to figure out when to set mode back to active.

    [EDIT]
    Umm... It looks bad when I change mode to anything but Active. Puppet immediately rotates to vertical position. Anything I can do to keep puppet rotation? By some reason IngoreLayerCollision is not enough, controller IS moving down, but puppet stays on the same position.

    [EDIT2]
    OK. Solved it. LayerSetup component was screwed up a little bit. Sorry Partel.
     
    Last edited: Jan 21, 2016
  42. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    416
    Partel,

    Actually it is the ragdoll that starts at the wrong position. I started doing some elimination and figured out the problem.
    The Ragdoll is repositioned when you have FBBIK and GrounderFBBIK on the character. Actually what happens is once you add those components, if you move the parent object of your character, the ragdoll does not move with it. And when you press play, for the first 3-4 frames the ragdoll is back at the original position and then quickly snaps to match the skeleton position. If I just deactivate grounder, the ragdoll starts correctly so it's actually grounder that causes the problem. But since GrounderFBBIK needs FBBIK to work, it's the combo of both of them.

    I tried to add FBBIK and Grounder in the Puppet Extended Demo scene to the pilot and oddly instead of the ragdoll being repositioned, the pilot armature starts at the incorrect position.

    Here is how to recreate the problem: (In Puppet Extended Demo scene)
    - Add FullBodyBipedIK to the Character Controller.
    - Create an empty gameobject parented to Character Controller and add GrounderFBBIK.
    - Make the FBBIK link from character controller to Grounder.
    - Select the water layer for ground in grounderFBBIK.
    - Now move ThirdPersonPuppet away from it's starting position.
    - Press Play

    I'll keep playing with it but it has something to do with GrounderFBBIK.

    I am using the FBBIK Bridge installation as well.

    Allan
     
    Last edited: Jan 21, 2016
  43. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hey,
    I followed those instructions, but didn't see anything starting from the wrong position. So I guess that problem is gone in 0.3. I will send you a PM...

    EDIT: The problem was not gone in 0.3, it's a bug in Final-IK instead, but it is easy to fix. Just add this line to GroundingLeg.cs line 59:

    Code (CSharp):
    1. IKPosition = transform.position;
    Cheers,
    Pärtel
     
    Last edited: Jan 22, 2016
    hopeful likes this.
  44. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    416
    Partel,

    Fantastic! That fixed it. That was a rare bug because it's only noticeable if you use grounder, FBBIK and PuppetMaster together and you end up doing something that affects the ragdoll in the first few frames of startup. In my case I was testing a physics based rope attached to the ragdoll and noticed how the rope behaved when attached at startup.

    Anyway, glad you found it. :)

    Allan
     
    Last edited: Jan 22, 2016
  45. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Great! Thanks for a very helpful bug report :)
     
  46. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    PuppetMaster 0.3 is now available :)
    Final-IK users don't forget to update to Final-IK 1.3

    Pärtel
     
    montyfi likes this.
  47. montyfi

    montyfi

    Joined:
    Aug 3, 2012
    Posts:
    548
    Wow! Amazing work! And that one button click to replace character... magical!
     
    hopeful likes this.
  48. montyfi

    montyfi

    Joined:
    Aug 3, 2012
    Posts:
    548
    From time to time I got situation when pupped drops on back and cannot go back into vertical position, keeps trying it forever. How could I improve stability? I want it to go to vertical position after 2 tries maximum.

    [EDIT] Another problem, I cannot make fall behavior work together with puppet behavior. It is always disabled runtime. Where should I look?
     
    Last edited: Jan 24, 2016
  49. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hey,
    The first question, increase "Get Up Collision Resistance Mlp" and "Get Up Knock Out Distance Mlp" in BehaviourPuppet.

    The other question. If you copied BehaviourPuppet from a puppet the didn't have the Fall behaviour, it will not switch to Fall when it looses balance. You'll have to go to the BehaviourPuppet's events, expand the "On Lose Balance" event and set it's "Swtich To Behaviour" to "BehaviourFall" and get rid of the animations called on the event.

    Pärtel
     
    montyfi likes this.
  50. montyfi

    montyfi

    Joined:
    Aug 3, 2012
    Posts:
    548
    Thank you again Pärtel! That's it!
     
    Partel-Lang likes this.