Search Unity

PuppetMaster - Advanced Character Physics Tool [RELEASED]

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

  1. ProtoSharkDev

    ProtoSharkDev

    Joined:
    Oct 3, 2021
    Posts:
    6
    How does the built in
    Code (CSharp):
    1. OnCollision
    work in Puppet master?

    I have an object I attached the script to.

    Code (CSharp):
    1.  
    2.  private void OnCollision(MuscleCollision m)
    3.     {
    4.         var muscle = npcPuppets.enemyPuppet.puppetMaster.muscles[m.muscleIndex].joint.name;
    5.         if (CharacterController.melee && damageImpact)
    6.         {
    7.             Debug.Log(m.collision.GetContact(0).point + " at joint " + muscle);
    8.             damageImpact = false;
    9.         }
    10.     }
    Yet whenever I do an "attack" with the player character, it seems to instigate the collision with the Left and Right foot.

    I do believe it's not the players character colliding with the melee weapon, because the layers are separate for weapon physics and unchecked. So they do not even register each other.

    I am also using A* for pathing and I wonder if that somehow may interfere, but I have my doubts.

    EDIT: nevermind I realized that the collisions returned were from the whole puppet rather than the collision event with the object. I have isolated with comparison of the weapon collider - not sure if it's the best way to go about it, but it worked.

    I'll leave this up in case anyone else gets confused and runs in to this.
     
    Last edited: Feb 26, 2023
    Partel-Lang likes this.
  2. Deleted User

    Deleted User

    Guest

    I get this error on every frame that puppetmaster is set to "Alive" trying to apply the PunPuppet script. Weird thing is it seems to only happen with one character. Any suggestions?

    NullReferenceException: Object reference not set to an instance of an object
    RootMotion.Dynamics.PUNPuppet.PuppetIsPinned () (at Assets/PuppetMaster-PUN2/PUNPuppet.cs:101)
    RootMotion.Dynamics.PUNPuppet.FixedUpdateLocal () (at Assets/PuppetMaster-PUN2/PUNPuppet.cs:127)
    RootMotion.Dynamics.PUNPuppet.FixedUpdate () (at Assets/PuppetMaster-PUN2/PUNPuppet.cs:116)
     
  3. xuantruongx98

    xuantruongx98

    Joined:
    Jun 18, 2022
    Posts:
    3
    When I spawn a lot of puppet master bot, some of them got the mesh go underground. Is there anything wrong?
     
  4. trzy

    trzy

    Joined:
    Jul 2, 2016
    Posts:
    128
    Hi Partel, thanks for the answer. I see it happen fairly frequently. I'm not calling Animator.Play() but rather using an animation controller with state transitions. Unity blends these and transition lengths are 0.25s with an exit time (so they should always be transitioning at the same points). I don't see any discontinuity. It's fairly random. There might be some collision between the puppet rig and environment objects but the environment objects are static and so there shouldn't be any major penetration that occurs.

    Not sure how to create a repro for you. It's quite sporadic. The best I could do is try to capture it in a video.
     
  5. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    What does that line 101 in your PUNPuppet.cs say? It's an empty line in my version.

    Hey,
    Is it just the mesh that goes underground or the ragdoll too? And how much is a lot?


    Yes, please try to send me a video, that could help, otherwise I'm in the blind here.

    Best,
    Pärtel
     
  6. Deleted User

    Deleted User

    Guest

    Thank you Partel, the problem seemed to correct itself somehow and doesn't send errors now.
     
  7. jefflin0424

    jefflin0424

    Joined:
    Oct 11, 2020
    Posts:
    8
    Hi Partel,
    How to set it so that the limbs of the doll will not be stretched


    Thanks,
     
  8. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hey,
    It's a general PhysX joint stability/quality issue so anything from here might help.
    Try increasing rigidbody solver velocity iterations, changing solver type in Physics Settings, enabling projection for the joints.

    Best,
    Pärtel
     
  9. ProtoSharkDev

    ProtoSharkDev

    Joined:
    Oct 3, 2021
    Posts:
    6
    Partel, any news on Havok integration? Still planning it?
     
  10. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,429
    Hey, Partel.

    [Edit: Skip this probably-FAQ] I have a character prefab with Animator, Final IK and a *lot* of additional logic, some of which depends on being without a parent object (if parent != null, it's a vehicle, etc.). I saw in the setup video how the wizard code makes a new root above the existing character and its new sibling puppet. In an earlier post, you said that you "can also just call puppetMaster.transform.parent = null; in Start()". It sounds like I can discard the new root parent entirely, and just make the puppet a child of the existing Animator/FinalIK/Logic prefab character as long as I separate it out in Start() before there are rigidbody/animator conflicts. The root was just an attempt to keep them "packaged"? Is that correct? [Edit: I see that advice a couple of places, so I expect the answer is yes.] [Edit again: works fine.]

    >> It seems like I need to babysit the root motion a little bit when trying to get back up to an animator-controlled root motion basis. After I go into ragdoll Dead state, the puppet is understandably thrown far from the rest of the Character. My game logic depends on the location of the Character. If I want to revive properly and not be dragged by an invisible string, I will need to somehow move the Character to be close to the ragdoll, but moving the Character while Dead just shoves the mesh rendering farther away. Is there a demo that shows how to do this? I initially dismissed BehaviourPuppet because I don't want anything triggering ragdoll state but my game, but if I set collision threshold high enough it doesn't seem to be a problem. I just want a simple "Play this Anim to Get Up Here", and BehaviourPuppet seems to be way overcomplicating things.
     
    Last edited: Mar 23, 2023
  11. chemicalcrux

    chemicalcrux

    Joined:
    Mar 16, 2017
    Posts:
    720
    I'm looking to make a character stagger, but never fall, when hit. I've tried calling the Hit function on MuscleCollisionBroadcaster components along with the BehaviourPuppet component, but that seems to always make the puppet fall over.

    I see some people talking about a BehaviourPuppetStagger component, but I don't see anything like that in the package.

    I did find a dropbox link to a .unitypackage, though. Is this just something that's provided separately from the rest of the package?

    edit: oh, I just realized that this the BehaviourPuppetStagger component is part of the FinalIK integration! That makes more sense.

    It's working decently now, but it's still possible to knock the puppet over. Is there a way I can set it up so that it never actually falls?
     
    Last edited: Mar 22, 2023
  12. ProtoSharkDev

    ProtoSharkDev

    Joined:
    Oct 3, 2021
    Posts:
    6
    Hey Partel,

    So I'm using explosion force to apply a knockback

    Code (CSharp):
    1.          foreach (var m in  puppet.puppetMaster.muscles) {
    2.             m.rigidbody.AddExplosionForce(charController.charStats.charImpactDamage * 20f, point, 0.5f,0.2f,ForceMode.VelocityChange);
    3.             }
    4.  
    My issue is that half of the time it works fine, the other half it ejects the ragdolls in to the sky like crazy. If I use less force, it ends up not applying any significant force apart from the one that gets hit by the melee weapon.
    I tried using "MuscleCollisionBroadcaster", but that ended up not applying any force at all that was visible. Even with 2000f. I'm using "Physics.OverlapCapsuleNonAlloc" for getting "collisions".


    EDIT: Seems also that even other explosion forces do not affect the puppet until after puppet is "killed". Even though I unpin it when applying forces.
     
    Last edited: Mar 22, 2023
  13. WunderfaxNick

    WunderfaxNick

    Joined:
    Jan 13, 2023
    Posts:
    1
    Hi there,
    it seems that if you want to set a puppet´s mode to disabled when the puppet is dead OR is unpinned, it immediately sets itself back to active. Is this intended or do I miss something?

    In my case it is needed to move my whole player to a certain position, while disabling PM and playing an animation. Starting point is the unpinned state of the Player´s puppet.
     
    Last edited: Mar 23, 2023
  14. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hey,
    Since it's for pro users only and you're probably the first to ever ask about it, I don't think it would make much sense for me to rewrite much of PM for it.

    Hey,
    Yes, you can have PM parented to the Animator object as long as you unparent it in Start. The reason is that PM ragdoll must not inherit any kinematic motion from its parents, it must be moved by PM's own physical forces only.

    Hey,
    If you set "Torque Mlp" in BehaviourPuppetStagger's Balancer settings to something like 3, it will make it much less likely to fall over, but it will still fall if pushed too hard. You could add a joint between the spine and a kinematic rigidbody to keep the body straight so it wouldn't fall, but it probably woulnd't also look very realistic.

    While the puppet is pinned, adding forces will be cancelled out by the pinning forces that are trying to keep the puppet pinned to its animation. You'll have to do it like in the "Puppet Raycast Hit" demo (RaycastShooter.cs).

    Hey,
    You can't disable a puppet while it is unpinned. Check out "Puppet Respawning" demo about teleporting a puppet to another location (regardless of its state).

    Best,
    Pärtel
     
    WunderfaxNick likes this.
  15. simonkingandaoking

    simonkingandaoking

    Joined:
    Dec 27, 2021
    Posts:
    19
    can i ask if there is a way to achieve this,for example if i do i perfect bock on a puppets swords,its arm reciol backwars and he steps back
     
  16. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    The easiest way would be, if you detect the block collision, reverse the attack animation and cross-fade to a stepping back animation at the same time. You can reverse animation speed if you add an Animator parameter "Attack Speed" and link it to the speed of all your attack animation states. Then call animator.SetFloat("AttackSpeed", -0.5f) or something like that. Don't forget to reset it to 1 when you start another attack of course.

    Best,
    Pärtel
     
  17. ProtoSharkDev

    ProtoSharkDev

    Joined:
    Oct 3, 2021
    Posts:
    6
    Thank you for the reply.

    It's not doing it for me. It's an issue I've been struggling for quite a while, trying to scout old posts and messages and applying methods suggested there.

    I also tried your suggestion that you gave some one else back in 2021 of just unpinning the whole puppet and adding force on every muscle.

    As I've mentioned in my post I did unpin it before applying forces. It doesn't seem to work until after the puppet is "killed".



    This was the original way I tried doing.

    Code (CSharp):
    1.     private void OrganicDamage(Vector3 point, RaycastHit hit)
    2.     {
    3.      
    4.         //gets the muscle id in the hierarchy
    5.         Transform rBodyTransform;
    6.         var musclePart = (rBodyTransform = hit.transform).GetSiblingIndex();
    7.         //root of the NPC
    8.         var rootParent = rBodyTransform.parent.parent;
    9.         //stats
    10.         var npcStats = rootParent.GetChild(2).GetComponent<NPCstats>();
    11.         var puppet = rootParent.GetChild(0).GetChild(0).GetComponent<BehaviourPuppet>();
    12.         puppet.Unpin();
    13.         // //applies force to every bone
    14.         foreach (var m in puppet.puppetMaster.muscles)
    15.         {
    16.             m.rigidbody.AddExplosionForce(charController.charStats.charImpactDamage * 4.5f, point, 0.5f, 0.2f,
    17.                 ForceMode.VelocityChange);
    18.         }
    19.         if (npcStats.alive)
    20.         {
    21.             npcStats.npcHealth -= charStats.pipImpactDamage;
    22.             EventManager.LimbCut(puppet.puppetMaster.muscles[musclePart].target, point, hit.rigidbody, npcStats);
    23.         }
    24.      
    25.         //enables cooldown
    26.         damageImpact = false;
    27.         DamageTimer();
    28.     }
    I also attempted the method in raycast example.

    Code (CSharp):
    1.     private void BatCast()
    2.     {
    3.         if (damageManager.damageImpact)
    4.         {
    5.             RaycastHit hitInfo;
    6.             for (var x = 0; x < rayOffsets.Count - 1; x += 2)
    7.             {
    8.                 var a = rayOffsets[x];
    9.                 var b = rayOffsets[x + 1];
    10.                 if (Physics.Linecast(startPos.position + a, endPos.position + b, out hitInfo,
    11.                         damageManager.combatLayer))
    12.                 {
    13.                     var broadcaster = hitInfo.collider.attachedRigidbody.GetComponent<MuscleCollisionBroadcaster>();
    14.                     if (broadcaster != null)
    15.                     {
    16.                         broadcaster.Hit(300f, (hitInfo.point - hitInfo.collider.transform.position) * 1500,
    17.                             hitInfo.point);
    18.                         Debug.Log("HIT ===========");
    19.                     }
    20.                 }
    21.             }
    22.         }
    23.     }
    Debug logs hit. Yet the forces do not until after puppet is "dead".

    Is there a place I could communicate more realtime with you to figure the issue out?
     
  18. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,429
    Thanks, Partel, appreciate the confirmation. Can you address the second question in my post? Repeated:

    After I go into ragdoll Dead state, the puppet is understandably thrown far from the rest of the Character. My game logic depends on the location of the Character. If I want to revive properly and not be dragged by an invisible string, I will need to somehow move the Character to be close to the final dead ragdoll, but moving the Character while Dead just shoves the mesh rendering farther away. (They both have parent=null.) Is there a demo that shows how to do this? I just want a simple "Play this Anim to Get Up Here", and BehaviourPuppet seems to be way overcomplicating things.
     
    Last edited: Mar 24, 2023
  19. Downbeat90

    Downbeat90

    Joined:
    Aug 18, 2021
    Posts:
    1
    Hi all and Partel,

    Great assets to start with. I just love both. Will write a review soon. I got 2 rookie questions. First, I have mimicked the PuppetMaster VR Boxing demo on my scene as a whole, with the same setup on my character. But my character doesn't respond to the punches as your dummy does. Its more like a Bobblehead, too wobbly. I adjusted the drag settings and pin-muscle weights and all but it just doesn't work for me as it does in your scene.

    The second question is, how do I setup the falling and getting up animations for it? Those GetUpSupine animations doesn't seem like they are attached to the animator controller and they don't seem to have events applied to them plus they are on a puppetmaster.fbx which doesn't seem like attached to any script or the main mesh renderer. Its a mystery to me. How do I apply my own to the BehaviorPuppet events?

    Since these might be pretty basic questions for most I'd love to hear from anyone who got an answer. Thanks a lot in advance!
     
  20. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hey,
    Where are you calling this code from? BehaviourPuppet updates its internal state in FixedUpdate so calling SetState does not have an immediate effect, it will be executed when BP executes it.
    If the source is something like OnCollisionEnter, then it might be that your call to unpin the puppet is executed a frame later and the pinning forces still cancel out your explosion forces. Try raising a flag to explode the puppet and explode it (add forces) from FixedUpdate.

    This code seems to explode the dummy in the "Puppet" demo just fine.
    Code (CSharp):
    1. puppet.SetState(BehaviourPuppet.State.Unpinned);
    2.  
    3.             Vector3 explosionPosition = puppet.puppetMaster.targetRoot.position;
    4.  
    5.             foreach (Muscle m in puppet.puppetMaster.muscles)
    6.             {
    7.                 m.rigidbody.AddExplosionForce(2000f, explosionPosition, 2f);
    8.             }
    Hey,
    The way BehaviourPuppet does it>
    While the puppet is unpinned, move the character to match the position of the pelvis rigidbody (muscles[0].rigidbody).

    When starting to get up, it's a bit more complicated. Take a look at BehaviourPuppetStateSwitching.cs.
    You gotta see if the ragdoll is prone or supine, move the target to the pelvis rigidbody again and play an animation.
    upload_2023-3-31_13-8-9.png

    Hey,
    1. Difficult to say what might be different between the two setups without seeing the project. Did you check rigidbody mass? individual muscle settings (expand Muscles on the bottom of the PuppetMaster)?

    2. Find the "Humanoid Third Person Puppet" animator controller.
    Copy the "BehaviourPuppet" and "BehaviourFall" sub-state machines and paste them into the animator controller you are using.
    upload_2023-3-31_13-12-18.png
    Create a transition from "BehaviourPuppet" sub-state machine to your idle or locomotion state.
    Then you can replace the animations in those sub-state machines if you wish to do so.
    BehaviourPuppet just calls cross-fade to those animation states by name.

    Best,
    Pärtel
     
  21. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,429
    Excellent, got it working.
     
    Partel-Lang likes this.
  22. ProtoSharkDev

    ProtoSharkDev

    Joined:
    Oct 3, 2021
    Posts:
    6
    So what I'm doing is calling the BatCast() as described above in the fixed update if a certain condition is met. That method then sends the signal through event - which then gets received by the explosion method as indicated above as well.

    Code (CSharp):
    1.     private void FixedUpdate()
    2.     {
    3.         if (charController.melee)
    4.         {
    5.             BatCast();
    6.         }
    7.     }
    8.    

    Maybe it's the order of my methods? Shouldn't unpinning happen at the same frame the function runs and then applying explosion?
     
  23. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hey,
    Are you also killing the puppet when you explode it? I found that calling puppetMaster.Kill() at the same time can cause this issue.

    upload_2023-4-6_13-58-27.png
    That code explodes the puppet reliably if added to the dummy in the "Puppet" demo at least.

    Best,
    Pärtel
     
  24. InfinityGameDev

    InfinityGameDev

    Joined:
    Jun 28, 2016
    Posts:
    54
    Hi Partel, what does PuppetMaster.FixedUpdate() [Invoke] mean in the profiler? It's taking up 15% of the CPU
     
  25. Partel-Lang

    Partel-Lang

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

    PuppetMaster does almost everything that it does from PuppetMaster.FixedUpdate() and there's a lot to calculate for active ragdoll stuff.

    Best,
    Pärtel
     
  26. Tarmack

    Tarmack

    Joined:
    Dec 16, 2016
    Posts:
    12
    Hey hello :)

    I'm currently having some Major issue with PuppetMaster and integration with multiplayer.
    We are using Fishnet (ticked based network solution) and the physics of our game server / client side is updated 30 times a sec as our server is 30 set on 30 ticks.
    This is due to performances since we want to have 200+ player on a single server.

    We have recently added PuppetMaster to our game on our new character controller, to emulate some better looking player interactions (when receiving a blow from a weapon etc...) but we are facing a major issue.

    The issue is the following one, according to what we are seeing so far, updating PuppetMaster manually between two physics steps, make it supper buggy, the fact is updating it only 30 times a sec, gives us super bad feelings on the animations and movements that this is overiding.

    We have tried many many differents things on our side but unfortunately for the moment we don't have any solution.

    Is there any recomendations that someone would have ?
    Note that the physics of Unity are updated on Ticks, and this should not change if we don't want to break all the rest of the feature of the game. as we are working on a mele combat game, FPC.
     
    JulienCornillon and XuX26 like this.
  27. LeifStro

    LeifStro

    Joined:
    Mar 23, 2015
    Posts:
    29
    Minor issue here, but its quite annoying. I'm using the Unity Recorder plugin to make gameplay videos for development/promotional purposes and it usually works well. However, puppet master seems to be incredibly jittery whenever I am recording. Puppet Master is smooth during gameplay, it just becomes jittery during recordings. I've attached a video in which Puppet Master is first disabled (smooth) then enabled (jittery). Any idea how to record puppet master and have it be smooth?
     

    Attached Files:

  28. LeifStro

    LeifStro

    Joined:
    Mar 23, 2015
    Posts:
    29
    I figured it out!
    On the Animator component - the Update Mode needs to be set to 'Animate Physics'. Then it runs nice and smoothly in both the game and during recordings.
     
  29. XuX26

    XuX26

    Joined:
    Jun 1, 2018
    Posts:
    1
    +1
    I'm also very interested by the answer
     
  30. TakeruGrima

    TakeruGrima

    Joined:
    Apr 7, 2018
    Posts:
    1
    I have the same issue with my project.
     
  31. JulienCornillon

    JulienCornillon

    Joined:
    Nov 17, 2022
    Posts:
    4
    I'm running into pretty much the same issue and would like to know if a solution exist for this. Setting animator to physics update work but make animation "lag" a bit I can see the animation is capped by the fixed update and it don't look very good since I'm in a FPS view. My game is running pretty smoothly with 150+ frame per seconds so it definitely feel "laggy", I tried using rigidbody interpolation but it barely help to have a better feeling.
     
  32. Tarmack

    Tarmack

    Joined:
    Dec 16, 2016
    Posts:
    12
    1. I've found a solution that seems to work but I still have a minor issue coming with it. I was hoping you were able to help me.
      The idea was to leave everything to puppet (animation, IK, etc) but add a lerp for the target transform to smooth the movement of each transform between physics updates.
      So before PuppetMaster.OnPreSimulate(), I'm "saving" each target transform position as "currentPosition".
      After PuppetMaster.OnPostSimulate() I'm "saving" the new position as "nextPosition" and I set the position for the transform back to the "currentPosition" saved earlier.
      Then during the update loop starting the next frame, I'm making a lerp between "currentPosition" and "nextPosition".
      So just before the next PuppetMaster.OnPreSimulate() the position of the transform is equal to the position after the previous PuppetMaster.OnPostSimulate().
      But it seems that my player body starts acting weird when I move it. I've made another video to show the result. I'm a bit clueless about why it happens and how to fix this.
     
  33. Tarmack

    Tarmack

    Joined:
    Dec 16, 2016
    Posts:
    12
  34. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    I'm sorry, I don't know anything about Fish networking, but looking at your last video, this kind of flickering usually happens when a script applying some changes to the pose is updated in FixedUpdate while animation plays every frame. Or the other way around. So basically the frames where you see the body weirdly rotated have some code not running or running multiple times (like when there are 2 or more FixedUpdates called in a single frame). I'd guess it's whatever code that rotates the pelvis bone. upload_2023-4-28_11-7-3.png

    Best,
    Pärtel
     
  35. LeifStro

    LeifStro

    Joined:
    Mar 23, 2015
    Posts:
    29
    Hey @Partel-Lang, I saw that the question was already raised a few years ago. I am looking for a way to get the Animator to work with Update: 'Animate Physics' - while using PuppetMaster and the Animancer plugin. Animancer doesn't seem to work with PuppetMaster when Update: 'Animate Physics', it only works with 'Normal' selected. The problem is there seems to be weird jerky behaviour on the character when all these plugins are in play and the Animator has Update: 'Normal'. This jerky behaviour is accentuated when recorder a video of gameplay using the Unity Recorder. Any ideas/suggestions would be appreciated.

    Here is a video of what recording a puppet master (using Unity Recorder) looks like when Animator - Update Mode: 'Normal'.


    Here is with Animator - Update Mode: 'Animate Physics':
     
    Last edited: May 11, 2023
  36. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hey,
    The problem is that in AnimatePhysics mode both PM and Animancer need control of updating the Animator. I have tried, but wasn't able to work around that issue. In Animate Physics mode PM needs to update the animation, process the pose and send the data to the muscles in FixedUpdate, before the PhysX update step. Maybe it can be solved from Animancer's side, but I think their code was in a dll.

    Best,
    Pärtel
     
  37. LeifStro

    LeifStro

    Joined:
    Mar 23, 2015
    Posts:
    29
    @Partel-Lang hey so I actually found a fix for this particular issue. I added the animancer component as a public variable in the PuppetMaster class, then instead of updating the animator (in the fixed update code), I instead update the animancer component. It works perfectly! Hopefully this helps someone in future, big thanks to @Kybernetik for his help aswell.
    (See images for code snippets).
     

    Attached Files:

    Liam2349, Partel-Lang and hopeful like this.
  38. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Oh, that's brilliant, why didn't I think of that :). Thank you so much for letting us know!
    Cheers,
    Pärtel
     
    hopeful likes this.
  39. Liam2349

    Liam2349

    Joined:
    Mar 10, 2016
    Posts:
    80
    Hi, I am having an issue with my puppet getting up at the feet, rather than at the hips. This is because my model (humanoid) has a strange armature, I think.

    In the screenshot, Game_Character is muscles[0] and is at the feet. I have found that in BehaviourPuppetStateSwitching.cs:189, the "get up" position is set to muscles[0]. For my model, if his feet are near a wall, he often hits the wall whilst getting up, and loses balance again.

    For my slightly strange model, changing this line to use muscles[1] works better, as this is closer to the hips.

    I attached a screenshot of your pilot model also, showing the difference.

    I am just wondering, is there a better solution to this problem than me adding some setting to the PuppetMaster component to use muscle 1 rather than 0? I would like to avoid modifying it if possible, but I'm not sure if this is fixable any other way.
     

    Attached Files:

  40. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hey,
    BehaviourPuppet component has get up offset prone/supine values under the Getting Up header, can use those to tweak it to the right position. Offsets are in character rotation space.

    Best,
    Pärtel
     
    Liam2349 likes this.
  41. Liam2349

    Liam2349

    Joined:
    Mar 10, 2016
    Posts:
    80
    Ah ok thanks this seems to be working well :)
     
    Partel-Lang likes this.
  42. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    hopeful likes this.
  43. Prith1

    Prith1

    Joined:
    Mar 26, 2020
    Posts:
    6
    How can I use behaviour puppet in runtime when spawning a puppet?

    basically I want to add a behaviour in runtime when I create a puppet in start
     
  44. Partel-Lang

    Partel-Lang

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

    Just instantiate BehaviourPuppet from a prefab and parent it to "Behaviours" after you've set up the PuppetMaster rig.
    BehaviourPuppet was designed to not have any direct references to the characters so you can just drag and drop from a prefab.

    Best,
    Pärtel
     
  45. Prith1

    Prith1

    Joined:
    Mar 26, 2020
    Posts:
    6
    @Partel-Lang I tried that, but when I parent it to behaviours it doesnt work as intended
    The puppet rigidbodies sometimes dont get the component MuscleCollisionBroadcaster

    I have this script attached to the normal characters and ai, and at start after a few seconds this function gets called "GeneratePuppet()"

    Code (CSharp):
    1.  
    2.  
    3. using System.Collections;
    4. using System.Collections.Generic;
    5. using UnityEngine;
    6. using Sirenix.OdinInspector;
    7. using RootMotion.Dynamics;
    8.  
    9. public class RuntimePuppetMaker : MonoBehaviour
    10. {
    11.  
    12. [Tooltip("What will the Puppet be named?")]
    13. public string instanceName = "My Character";
    14.  
    15. [Tooltip("The layer to assign the character controller to. Collisions between this layer and the 'Ragdoll Layer' will be ignored, or else the ragdoll would collide with the character controller.")]
    16. public int characterControllerLayer;
    17.  
    18. [Tooltip("The layer to assign the PuppetMaster and all its muscles to. Collisions between this layer and the 'Character Controller Layer' will be ignored, or else the ragdoll would collide with the character controller.")]
    19. public int ragdollLayer;
    20.  
    21. [SerializeField] BehaviourPuppet puppetBehaviourPrefab;
    22.  
    23. [Button]
    24. public void GeneratePuppet()
    25. {
    26. // Find bones (Humanoids)
    27. BipedRagdollReferences r = BipedRagdollReferences.FromAvatar(GetComponentInChildren<Animator>());
    28.  
    29. // How would you like your ragdoll?
    30. BipedRagdollCreator.Options options = BipedRagdollCreator.AutodetectOptions(r);
    31.  
    32. // Edit options here if you need to
    33. options.headCollider = RagdollCreator.ColliderType.Box;
    34. options.handColliders = RagdollCreator.ColliderType.Box;
    35. options.chest = false;
    36.  
    37. // Create the ragdoll
    38. BipedRagdollCreator.Create(r, options);
    39.  
    40.  
    41. Transform ragdoll = this.transform;
    42. ragdoll.name = instanceName;
    43.  
    44. // This will duplicate the ragdoll character, remove the ragdoll components from the original and use it as the animated target.
    45. var item = PuppetMaster.SetUp(ragdoll, characterControllerLayer, ragdollLayer);
    46. Debug.Log("A ragdoll was successfully converted to a Puppet.");
    47.  
    48.  
    49. //trying to instantiate behaviour
    50. var newBehaviour = Instantiate(puppetBehaviourPrefab, ragdoll.root.GetChild(0));
    51. }
    52. }
    53.  
    54.  
    I tried a few variations of creating/moving the behaviour puppet component, none of them seemed to work (moving from sibling, spawning before/after creating puppetmaster, using existing puppets etc)

    Im trying to get the raycasthit demo to work

    I want to be able to create a puppet in runtime and then have it interact with the raycast hit script in the demo.

    To recreate what I've tried, I duplicated the dummy from the dummy root in the demo, added the above script to it and tried playing the demo by shooting raycasts at it but it didnt seem to work. I also tried with 2 different models, still no luck. Can u please help me out?

    At this point I cant tell whether the fault is in the behaviour puppet or the raycast script


    In the end I just want to be able to create a puppet in runtime and then have it interact with the raycast hit script in the demo.
     
  46. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hey,
    Sorry, you're right, it's a bug. PM inits at Awake, which is before you instantiate the behaviour, and it won't look for them again.
    Please grab this patch, use public static PuppetMaster SetUp(Transform target, int characterControllerLayer, int ragdollLayer, params BehaviourBase[] behaviourPrefabs ). Do not instantiate the behaviour anymore, call that SetUp with the behaviour prefab(s)

    Best,
    Pärtel
     
  47. Prith1

    Prith1

    Joined:
    Mar 26, 2020
    Posts:
    6
    Im unable to download the patch
     
  48. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Ah, crap, forgot to add the link, sorry!
     
  49. Dmeowmixer

    Dmeowmixer

    Joined:
    Jan 25, 2015
    Posts:
    12
    Hello Mr. Partel,

    We're running into a strange issue and was hoping you might have come across it before or know what's going on off-hand.

    We are importing models from Reallusion Character Creator 4 and when adding Puppetmaster the models, its limbs are being sucked into its own body ( everything past the knees and elbows ).

    Seen here:


    We are following the basic guide you provided here:
    for setup and are not doing anything special with these models before importing them into Unity. They are fully rigged/weight-mapped by default and are working prior to enabling PuppetMaster ( tested step-by-step and it still working when enabling the Character Controller, Full-body Biped IK, running the Biped IK Ragdoll Creator ). It is only experiencing this error after clicking the "Set Up PuppetMaster" button in the PuppetMaster component. While the animations work as expected before enabling PuppetMaster, after enabling the Biped IK Ragdoll it looks like the knees are being sucked toward a void ( not sure if this has something to do with it ) I attached an image of the ragdolled model with its knees being sucked toward the center.

    I have sent you an email via contact@ with an example model from the Character Creator and was hoping you could check it out and let us know if there's a conflict with the Reallusion Character models or if it's just us.

    Thank you very much Mr Partel.
     

    Attached Files:

  50. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,552
    Hey,
    I thing you might be running a previous version of PuppetMaster, that problem should be fixed in the latest. If you don't feel like updating, just enabling "Support Translation Animation" in PM ought to fix it too.

    Best,
    Pärtel