Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

PuppetMaster - Advanced Character Physics Tool [RELEASED]

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

  1. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,131
    Did you try just increasing the mass of the cannon ball?
    If so, then you could use OnCollisionEnter, check if it is a cannonball and add additional force to the ragdoll rigibody that was hit in the direction of cannonBall.rigidbody.velocity.
     
    ppizzinini_clockstone likes this.
  2. ferverence

    ferverence

    Joined:
    Jul 15, 2014
    Posts:
    22
    Hello @Partel-Lang just wondering if you have tested this on 2019.4 LTS? Last I used this was U5 :) But would like to pop it into current project - Thanks!!!
     
  3. MetalDonut

    MetalDonut

    Joined:
    Feb 7, 2016
    Posts:
    119
    Hi All - Any ideas on how to keep a 3D character on a 2D axis with puppetmaster?

    I have a 2.5D platformer (so plays only on the X and Y axis) but uses 3D assets. The character can only move left and right. When I make him ragdoll, I don't want him falling too far off the Z access. Would love some ideas on how I might be able to achieve this? I tried putting invisible colliders either side of the character, but it doesn't look natural when he falls against it. Other ideas?

    Thanks!
     
  4. Milionario

    Milionario

    Joined:
    Feb 21, 2014
    Posts:
    43
    How can I have two or more Behaviours active at the same time? For example I want to have the stagger behaviour and also another self made behaviour that detects impacts on muscles and does some other stuff, using OnMucleCollisionBehaviour

    OnMucleCollisionBehaviour works even if the script is disabled but I also need access to the Start and Update methods to do some stuff.

    Also how does puppetmaster decide which behaviour is active one on the start of the scene if i have more than 1 behaviour as a child of Behaviours gameobject?

    Am I wanting to do this right or I don't understand behaviours?

    Or how can I subscribe to muscle collisions without behaviours?
     
    Last edited: Jun 25, 2020
  5. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,131
    Hey,
    Yeah, go ahead, I haven't found or heard of any problems with 2019.4.

    I think you should be able to use Freeze Position under Rigidbody's Constraints for that. There is a 2.5D example included in the package, check out the "Goblin Archer" demo under Plugins/RootMotion/PuppetMaster/_Integration.
    It requires the free Goblin Archer art package, so install that first.

    Hey
    If you have multiple behaviours then this is how they are managed:
    If BehaviourPuppet is present and enabled, it will be the first behaviour activated when the game starts.
    If BehaviourPuppet is disabled, the next behaviour (whatever that is) will be activated first.
    So for example if you have this:
    - BehaviourPuppet
    - BehaviourBipedStagger
    - CustomBehaviour

    And you disable BehaviourPuppet, it will start with stagger. If you move CustomBehaviour above stagger, it will start with that.

    About OnMuscleCollisionBehaviour, that gets called on your custom behaviour even if it is not currently the active behaviour, so you should be able to use that when currently staggering or whatever.

    Best,
    Pärtel
     
    ferverence likes this.
  6. Milionario

    Milionario

    Joined:
    Feb 21, 2014
    Posts:
    43
    But I would like access to the OnUpdate methods also, is there a way to have access to OnMuscleCollisionBehaviour and OnUpdate without having to turn off other behaviours? What im trying to do is record the time of the last collision on each muscle, the way i would do it is by ticking them on update and applying time.deltaTime to its current elapsedTime. But i guess that could be done with OnMuscleCollisionBehaviour but using some other math and time values from unity...
     
  7. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,131
    You could use PuppetMaster.OnRead delegate to get a call from PM before every update:
    Code (CSharp):
    1.  
    2. protected override void OnInitiate() {
    3. puppetMaster.OnRead += OnPuppetMasterRead;
    4. }
    5.  
    6. void OnPuppetMasterRead() {
    7. // This will run every frame
    8. }
    But you don't need to tick a timer every frame to keep track of last collision time.
    You can just do lastCollisionTime = Time.time when a collision happens, then
    float timeSinceCollision = Time.time - lastCollisionTime; whenever you need to use it for whatever.

    Best,
    Pärtel
     
  8. 91dead91

    91dead91

    Joined:
    Mar 22, 2016
    Posts:
    2
    Hi! I'm wondering, may this puppet master or final IK grab and move other object(like enemies, cars, trash cans and etc)? I want to know, can i implement habits like in gang beasts stuff?
     
  9. Milionario

    Milionario

    Joined:
    Feb 21, 2014
    Posts:
    43
    Does on OnRead gets called on non active behaviours too?

    And yes, thats exactly what I was hoping to do with collision time, thanks for giving me confidence!
     
  10. CoryRobertson

    CoryRobertson

    Joined:
    Mar 12, 2018
    Posts:
    11
    Apologies, I meant to post this here in the PuppetMaster thread instead of the IK thread.

    Hi Partel!

    I bought both your FinalIK and PuppetMaster, and I'm slowly getting the hang of using them. They're amazing, but I'm having some issues figuring out a few things. I'm building a physics-based VR action game, and I'm working on the enemies. Right now each enemy has their Ragdoll, PuppetMaster, PuppetBehaviour, and FallBehaviour set up. And I've been using these scripts:

    Character Controller
    1. User Control AI.cs
    2. Character Puppet.cs
    3. Aim IK.cs (I tried to use Aim Swing.cs as well, but for some reason my character won't track the target if this script is active)

    Animation Controller
    1. Character Animation Third Person.cs
    2. Humanoid Third Person Puppet.controller

    So far, my enemies will run to the target and then enter their idle mode in Grounded Directional like they're supposed to, but I can't understand the scripts on how you set the Action Index for that animator controller in order to start animations that are in Actions. So my main questions are:

    1. How should I make the scripts that control the animator/attack animations and what to do when the characters reach the target? Should I make my own, or use one of the scripts you created?

    2. For tracking targets and movement, is User Control AI the best option, or should I go with NavMeshPuppet.cs and Nav Mesh Agent?

    Thank you!
     
  11. Milionario

    Milionario

    Joined:
    Feb 21, 2014
    Posts:
    43
    I am trying to instantiate my puppets prefabs with puppetmaster disabled, my character is able to move around normally because of its character controller and animations, but when I activate puppetmaster(thats when i need to simulate physics collisions) it gives me the following errors.

    upload_2020-6-30_11-44-24.png

    The reason I need to do this is that if I try to instantiate the puppets with puppetmaster enabled already it causes a slight hiccup in my game, takes about 3-5 ms to instantiate against with puppetmaster off which takes 1ms to instantiate, what I am doing right now is instantiating it with puppetmaster ON but switching it off 1 frame later, that works but still make my game drop frames when I instantiate them.

    What i wanted was to only enable puppetmaster when i actually need, my character skinned meshes could be at any position when I want to activate puppetmaster , how do i not cause these errors?

    Also keep in mind that I am also using BehaviourPuppet and BehaviourBipedStagger on this setup
     
    Last edited: Jun 30, 2020
  12. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,131
    Hey,
    Final IK would allow you to pick objects up accurately (using the InteractionSystem), but that would not be physically simulated. PuppetMaster is for all the physics stuff, so if you were looking into something like gang beasts, that's what you will need more. You can attach joints between your puppet's hand and an enemy and that's how it would work.
    Not sure what you meant exactly by habits, but those things would have to be custom scripted.

    Hey, just replied to you in the FIK thread.

    Those errors appear because the ragdoll pose does not match with the animated target when you initiate. That is because animation is already running when you initiate at a later time. When joint gameobjects are activated in Unity, joint default orientations will be calculated automatically and it is not possible to recalculate/change them anymore (silly PhysX implementation problem), so even if I forced the poses to match, joint limits would still end up all messed up.
    What I usually do is initiate all the puppets I need in a level at the start of the game. Since you are loading the scene anyway, nobody will notice the spike at the start of a scene. If you have a lot of puppets, you should use pooling and reuse the ones that get killed (see the "Puppet Respawning" demo about that).

    Cheers,
    Pärtel
     
  13. Milionario

    Milionario

    Joined:
    Feb 21, 2014
    Posts:
    43
    Haha its funny how I am always doing what you will later suggest me, I implemented pooling at the start of the game and turn off unused puppets, it works well, thanks partel!

    By the way:
    Should i always use Teleport instead of moving around just the gameobject that contains the animator(because i am turning off puppetmaster when not needing it), if it want to move it back and forth between the pool and the game?
     
    Last edited: Jul 1, 2020
  14. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,131
    Cool, hehe,
    Yeah, use Teleport to move between the pool and the game. Moving only the animator object would leave the ragdoll behind and PuppetMaster will have to fly the ragdoll across the map to catch up.
     
    Milionario likes this.
  15. Partel-Lang

    Partel-Lang

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

    We finally have a working integration package for Opsive's UCC v 2.2.3.
    You can grab it from here. Will be added to _Integrations folder too in the next PM version.

    Cheers,
    Pärtel
     
    Last edited: Jul 4, 2020
    MostHated likes this.
  16. sancha-km

    sancha-km

    Joined:
    Jun 5, 2016
    Posts:
    30
    Hi,
    Question about main puppet master script
    How Freeze is actualy working in Puppet master state?
    When i set it, it always switch back to Active on next frame.
     
  17. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,131
    Hey,
    Did you mean it always switches back to Alive?
    Might be confusing Mode and State here.

    When you set State to Frozen, it will switch Mode to Active so puppet could die and freeze (deactivates ragdoll when the puppet is finished dying and rigidbodies are asleep).

    Here's some more intel on modes and states:

    States:
    Alive - normal puppet behaviour.
    Dead - starts a dying sequence, blending out pin and muscle weights, disables animation when done.
    Frozen - same as Dead, but deactivates ragdoll eventually.

    Modes:
    Active - physics is actively simulated using forces.
    Kinematic - no forces used, ragdoll rigidbodies have isKinematic enabled, colliders enabled in case you need to raycast against them.
    Disabled - ragdoll deactivated, PuppetMaster on stand-by mode.

    When State is set to Dead or Frozen, puppet will always be switched to Active mode as ragdoll simulation is needed for dying.

    Best,
    Pärtel
     
  18. sancha-km

    sancha-km

    Joined:
    Jun 5, 2016
    Posts:
    30
    Yes, it always switches back to Alive

    What is the best way to simulate INSTANT Ice Freeze effect in the game on puppets?
    So far, i was able do it only by disabling PuppetMaster script.

    Not the best variant, because damage effects don't work sometimes.
     
    Last edited: Jul 4, 2020
  19. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,131
    Oh I see. This works when I apply it in the "Puppet" scene:

    Code (CSharp):
    1. public class InstaFreeze : MonoBehaviour {
    2.  
    3.     public PuppetMaster puppetMaster;
    4.  
    5.     private void Start()
    6.     {
    7.         puppetMaster.fixTargetTransforms = false; // Do not reset target transforms to default pose every frame
    8.         puppetMaster.blendTime = 0f; // Blend to Kinematic mode instantly
    9.     }
    10.  
    11.     private void Update()
    12.     {
    13.         if (Input.GetKeyDown(KeyCode.F))
    14.         {
    15.             puppetMaster.mode = PuppetMaster.Mode.Kinematic;
    16.             puppetMaster.targetAnimator.enabled = false;
    17.         }
    18.     }
    19. }
     
  20. alexkarak

    alexkarak

    Joined:
    Feb 7, 2018
    Posts:
    28
    Hey Partel

    I am trying to improve my AI puppets and i am running in some problems!
    I have a navmesh agent to move the puppets and also using behaviour designer!

    BUT....when my puppet collides with something and unpins the agent keeps going!
    and when the puppet is back up it faces the direction in witch it fell and not the direction it is heading to!
    I tried to diactivate the agent (with the script bellow) but when it is enabled again the puppet breaks and fly into the air!


    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.AI;
    5. using RootMotion.Dynamics;
    6. using BehaviorDesigner.Runtime;
    7.  
    8.  
    9. public class PuppetNavMEsh : MonoBehaviour
    10. {
    11.     public NavMeshAgent navAgent;
    12.     public BehaviourPuppet puppet;
    13.     public CharNav charnav;
    14.     public BehaviorTree behaviorTree;
    15.     // Start is called before the first frame update
    16.     void Start()
    17.     {
    18.        
    19.     }
    20.  
    21.     // Update is called once per frame
    22.     void Update()
    23.     {
    24.         if (puppet.state == BehaviourPuppet.State.Unpinned)
    25.         {
    26.             behaviorTree.enabled = false;
    27.             navAgent.enabled = false;
    28.             charnav.enabled = false;
    29.         }
    30.         if (puppet.state != BehaviourPuppet.State.Unpinned)
    31.         {
    32.            
    33.             navAgent.enabled = true;
    34.             charnav.enabled = true;
    35.             behaviorTree.enabled = true;
    36.         }
    37.     }
    38. }

    here is the script! i am pretty sure i am doing something wrong!
     
  21. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,131
    Hey,
    Which gameobject is the NavMeshAgent on? Is it the one with the Animator or the root of the entire rig?
    Make sure it is on the same gameobject as PuppetMaster's "Target Root".
    Maybe you have another script somewhere that forces navAgent.enabled = true?

    There is a "NavMeshAgent" demo scene, that does pretty much the same thing just without Behaviour Designer and works, did you check that out?

    Best,
    Pärtel
    Best,
    Pärtel
     
  22. alexkarak

    alexkarak

    Joined:
    Feb 7, 2018
    Posts:
    28
    i changed the prop root to be the character controller GameObject and it worked! This will couse me issues with puppetmaster?
     
    Last edited: Jul 9, 2020
  23. tssai

    tssai

    Joined:
    Feb 12, 2018
    Posts:
    2
    Hello Partel!

    I design a melee game with kinect.
    My vedio


    I have a question with puppetMaster.

    In the vedio, the pilot is very springy.

    But I do not want the pilot spriny when be hit back position.
    I want more smooth when be hit back.

    This is GTA5 Melee vedio

    Like 2:00 ~2:05. this is good punch feel.

    Well I do some test
    1. Increase muscle damper
    2. Increase collision resisitance
    3. Increase the pilot mass
    But Not effective work.

    This is my setting
    upload_2020-7-9_15-43-48.png
    upload_2020-7-9_15-45-18.png


    Do you have some good suggest?

    Sorry for my poor english.
    Thank you!
     
  24. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    204
    Hi Pärtel,

    I am interested in doing something similar. What I am trying to do is in certain circumstances is let the puppet fall, then exit behaviour puppet, and let the animator take over, where i would initiate a crawl or backwards crawl animation (e.g. through paramater CrawlBackward, CrawlForward)

    As far as I can tell, when losing balance the animator moves into the behaviourpuppet animation layer, where it runs the puppetfall, and then uses getupsupine or getupprone, then exits and lets the animator take over again. I cant find the code where you determine when behaviourpuppetshould use getupprone or getupsupine. Q1, where is this code?

    Q2 Would I need two more animations in behaviourpuppet animation layer so that I can transition to the crawl positions (backward or forward crawl?
     
  25. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,131
    Hey,
    Not 100% sure without seeing the project, but if it works, great :)

    Hey,
    Please import the "VR Boxing" package from Plugins/RootMotion/PuppetMaster/_Integration, it has a VRPuppet.cs component added to the puppet. That is an add-on script designed for VR where you are able to touch puppets with your hands, it adds some drag to the muscles and that should get rid of the rubber chicken effect. Set it up on your puppet like it has been set up for the demo dummy. Playing the demo requires Oculus hardware and utilities, but you can just snatch the script from the demo.

    Hey,
    BehaviourPuppet doesn't take control of the Animator really, all it does is crossfade to the PuppetFall animation when it loses balance and gettting up animation at the start of getting up. You are free to crossfade to any other state in between. So to start crawling while unpinned, set behaviourPuppet.canGetUp to false so it would not attempt to rise and just do animator.CrossFadeInFixedTime() to any crawling animation you like. You can check behaviourPuppet.IsProne() to see whether the puppet is currently prone or supine and choose which crawl animation to play based on that.

    You can add your crawl animations to BehaviourPuppet sub-state machine (that is not a layer). They don't necessarily have to be in that sub-state machine, but better to have them all in one place.

    Cheers,
    Pärtel
     
  26. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    204
    Pärtel, It sounds like that would work well. 1 more question about it....once I do the above and have started my final animation (crawl), will I be able to set puppetmaster to disabled? In otherwords will it exit BehaviourPuppet Substate machine(you can’t disable puppetmaster from Within the substate.
     
  27. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,131
    Hey,
    You can't disable PM while unpinned. But what you could do instead is replace the animation states in On Get Up Prone/Supine events on the bottom of BehaviourPuppet with your crawling animations. Then it would "get up", but just crawl instead of standing up. Then you can disable PuppetMaster again.
     
  28. ChrisCoool

    ChrisCoool

    Joined:
    Jul 3, 2017
    Posts:
    7
    Hello Partel, I am using PuppetMaster withTimeline. it works well when Animator's Update Mode is 'Normal'.
    However, when I switch the Animator's Update Mode to 'Animate Physics', the avatar remains T pose. I wonder if there is a way to make PuppetMaster to work with Timeline when Animator's Update Mode is 'Animate Physics'.

    Thanks a lot!
     
  29. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    204
    I would need a conditional replace of animation (even if I have to alter your code, I just don't know where to do this). in otherwords, sort of like your muscle detatch example, walk normally, or hop when missing 1 foot/leg. The reason I cant use this a base is that your example still uses the getup animation, and then switches to the special movement animation (hop). So in your example you can disable PM as you are no longer in the unpinned state. What I am looking for is:

    Missing walking limb?
    YES? Transition to Crawl position, exit unpinned state, let animator take over crawl.
    NO? Transition to get up position, exit unpinned state, let animator take over walk/idle. (This is what happens currently)​

    I need it to happen like this because I need to disable PM, and as you mentioned I can not do this while unpinned. I need to disable PM as it is very heavy on performance, so its preferable to switch it on and off when required/not required (as you have noted in your performance tips).
     
  30. CoryRobertson

    CoryRobertson

    Joined:
    Mar 12, 2018
    Posts:
    11
    Hi Partel,

    I'm trying to use a modified version of your Grab.cs script in VR, but whenever I grab an enemy, they usually bounce around erratically instead of staying in place. Is this because of the Configurable Joint settings, or do I need to change something about my VR hands?

    Update: Solved. The issue was the constant pinning forces to/from the other muscles fighting the joint. Using the VR Puppet script to lower them on contact and now it works beautifully.

    However, I have another question. The Dynamic Anchors for VR hands are really jittery when I try to move around (I'm using a rigidbody/collider setup on my VR player object). Any movement leaves the objects trying to play catch up with the anchors. Any way to solve this?

    Thanks as always!
     
    Last edited: Jul 18, 2020
  31. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,131
    Hey,
    In AnimatePhysics mode PuppetMaster updates the Animator from FixedUpdate, so that's probably why it is not working, but I can't think of a way to make it work like that, sorry.

    Hey,
    No need to alter PM code.
    Instead add a public void OnGetUpProne() and OnGetUpSupine() to the script you use to control your puppets. Then go to the Events section on the bottom of BehaviourPuppet. You'll see "On Get Up Prone" and "On Get Up Supine" events there, expand them and set Animations size to 0. Each puppet event has a Unity Event, click on the + button to make it fire the OnGetUpProne/Supine functions of your script.
    Then you can call whatever animation you need based on any condition you need from those OnGetUpProne()/OnGetUpSupine() functions.

    Hey,
    If you match fixed delta time to your VR device frame rate, it should become smooth.
    Code (CSharp):
    1. Time.fixedDeltaTime = 1f / XRDevice.refreshRate;
    But as DynamicAnchors use forces to catch up, there will always be some lag as the rigidbodies need to accelerate towards the target.

    Best,
    Pärtel
     
    nobluff67 likes this.
  32. ChrisCoool

    ChrisCoool

    Joined:
    Jul 3, 2017
    Posts:
    7
    Hi Pärtel!Thanks for your reply.
    I find out that in FixedUpdate the Animator is disabled and in Update the Animator is enabled again. In FixedUpdate, after targetAnimator is disabled, targetAnimator calls Update(). I think maybe this is where the transforms get updated. However when working with Timeline, I find out that even though we call the targetAnimator.Update(), transforms will not get updated. Maybe this is why avatar doesn't move.

    So I try to comment out the code where the animator is disabled and it works. So when working with Timeline and Animator's mode is Animate Physics, PuppetMaster's updateMode is more like Legacy.

    Please correct me if I am wrong.

    Thanks a lot!
     
  33. CoryRobertson

    CoryRobertson

    Joined:
    Mar 12, 2018
    Posts:
    11
    Okay great, I'll try that. Thank you.

    Also, is there a way to only activate the physical following hands on touch? So they follow perfectly when moving around, but become physical hands when pushing an object or punching?
     
  34. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    204
    Thanks Pärtel, works perfectly.
     
  35. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,131
    Hey,
    I haven't really tested PM with Timeline, didn't think it would be possible at all. But I think you are right and if it works like that then great. :)

    Hey,
    You should be able to set DynamicAnchor's rigidbody to kinematic, set isTrigger true for the collider. When the collider is triggered, set it back to non-kinematic and isTrigger to false, Could add a timer to reverse all that after a few seconds or so.

    Cheers,
    Pärtel
     
  36. Sujeto

    Sujeto

    Joined:
    Jun 30, 2015
    Posts:
    9
    Hello!! I'm integrating Puppet master with game creator and I got it working now! the problem is when I let the ragdoll fall and it moves when the character stands up again it moves inside the character controller so it isn't in the center anymore, is there a way to avoid that kind of movement? Thanks!!
     
  37. Sujeto

    Sujeto

    Joined:
    Jun 30, 2015
    Posts:
    9
    Soo i found the solution, the root in the puppet master must be the character controller and no the model with the animator so now it works like a charm! thanks a lo for this awesome tool Partel!!!
     
    Partel-Lang likes this.
  38. kamihiro74

    kamihiro74

    Joined:
    May 15, 2013
    Posts:
    18
    Hi! I'm using Puppet master and Final IK to create the fighting type of game, so far, I'm trying to make the punching action by using Aim IK and Puppet master. I got it work by using one of your sample AimBoxing from FinalIK but I got some question about it.

    1. Do I need to attach the Aim Boxing to the target ?

    2. What is this punch-pin gameobject uses for ? if this is make arm rotates toward the target why is not the same position as target ?

    3. is there any other way to accomplish boxing movement like AimBoxing?
    I watched the tutorial on youtube, it was using Aim weapon, Can you give me the sample using AimBoxing with Puppet master?

    Sorry, for a such question, I know there is comment on AimBoxing script but I'm so dumb can't understand it....
    if you can explain this for me that would be great. Thank you!
     
    Last edited: Jul 29, 2020
  39. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,131
    Hey,
    Please check out the Aim Controller demo. That is a helper tool for AimIK that takes care of most of the stuff you'd ever need to do with AimIK, like target switching, weight smoothing, etc. Basically you'd just change aimController.target and set it to null if you wish to disable aiming.
    If you enable "Use Animated Aim Direction", they you will be able to use it with boxing and sword swinging animations.

    Best,
    Pärtel
     
  40. kamihiro74

    kamihiro74

    Joined:
    May 15, 2013
    Posts:
    18

    Thanks! it works great!!
     
    Partel-Lang likes this.
  41. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    413
    Bug in PuppetMaster:

    Partel,

    I've been getting the following error when my PuppetMaster character loses balance during a collision with an enemy character. I am unable to trace the source of the error. I think it has something to do with the Exit time during transitions between states in the Mecanim Animator component. But the error is caused by PuppetMaster and it should not matter what Exit time is used during transitions. My PuppetMaster characters all use Update Mode Animate Physics since my game is physics based. Unity 2019.4.6

    Invalid time range for Transition exit time condition
    UnityEngine.Animator:Update(Single)
    RootMotion.Dynamics.PuppetMaster:FixedUpdate() (at Assets/Plugins/RootMotion/PuppetMaster/Scripts/PuppetMaster.cs:988)

    Double clicking the error messgage takes me to the following code in PuppetMaster on line 988:
    Code (CSharp):
    1. if (targetAnimator.enabled || (!targetAnimator.enabled && animatorDisabled))
    2.                 {
    3.                     targetAnimator.enabled = false;
    4.                     animatorDisabled = true;
    5.                     targetAnimator.Update(Time.fixedDeltaTime);   (This is line 988)
    6.                 }

    EDIT: I found the problem. I was using animator.crossfade passing in an int value of 0 as a HashID. I had a HashID variable that I had not provided a value and it was defaulted to 0. I'm not sure why the error message pointed to Line 988 in PuppetMaster fixedUpdate instead of referencing the animator.crossfade command.

    Thanks
    Allan
     
    Last edited: Aug 6, 2020
    Partel-Lang likes this.
  42. ebruinsSCI

    ebruinsSCI

    Joined:
    Aug 4, 2020
    Posts:
    1
    Hey Pärtel,

    Just wondering if you had gotten the Puppetmaster package working with the new Animation Rigging package?
    The IK doesnt appear to be activating when i'm enabling it.

    I've also tried to do some IK with Final IK and PuppetMaster, but have been getting some weird results, possibly due to the amount of bones required for Arm_IK.

    Would it be safe to reduce the amount of bones the Arm_IK needs?
    We only have 3 bones which are:
    hand
    ForeArm
    UpperArm

    We dont have a shoulder bone on our rigs
     
  43. MetalDonut

    MetalDonut

    Joined:
    Feb 7, 2016
    Posts:
    119
    I'm wondering what the best way to knock a character down (i.e falls over when hit) without being completely knocked out? I've been using .Kill() but this goes into a complete soft ragdoll which isn't natural if the player was simply knocked over but is still conscious. Would love some advice on best method to use here? Thanks!
     
  44. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,131
    Hey,
    Go with LimbIK, that uses 3 bones.
    Does Animation Rigging work when you switch Animator to Normal update mode?

    Hey,
    Call behaviourPuppet.SetState(BehaviourPuppet.State.Unpinned);

    Best,
    Pärtel
     
  45. Arlatan

    Arlatan

    Joined:
    Jun 23, 2020
    Posts:
    4
    Good morning, Pärtel!

    I purchased the Final IK and Puppetmaster assets a few days ago and I'm trying to play around with the hit reactions, but I can't seem to get it right. I'll admit I'm a novice. I just starting programming a few months ago.

    Basically I dropped a "player" into the demo hit reaction scene that swings a sword with several markers on it that are shooting some rays, checking for colliders, and then attempting to add force. I get a debug line saying which parts I am hitting with the sword, but I can't seem to get any response from the dummy. Any advice would be great!

    Best regards.
     
  46. gliealonso

    gliealonso

    Joined:
    Oct 21, 2018
    Posts:
    68
    Hi Arlatan!

    Maybe some examples of your code and images would be good so it's easier to understand what's going on =)

    Warmest regards,
    Gabriel.
     
  47. Arlatan

    Arlatan

    Joined:
    Jun 23, 2020
    Posts:
    4
    Of course. So I placed some markers on a sword that are doing some raycasting. Ideally, they will strike the colliders and the colliders on the dummy will recognize the impact and receive force accordingly. Currently, everything is pretty messed up from trying to implement it with finalIK's hitReaction, so this is the code I was using originally prior to my investment.

    As I said, I'm a bit of a novice, so any insight would be welcomed. I've gone through many tutorials/Udemy courses and and am now trying to do something on my own, which is an entirely different beast. But! I won't give up. Thank you for your help!

    Cheers,
    Arlatan


    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using RootMotion.Dynamics;
    4. using RootMotion.FinalIK;
    5. using UnityEngine;
    6.  
    7. public class SwingMarker : MonoBehaviour
    8. {
    9.     Vector3 fromPosition;
    10.     Vector3 toPosition;
    11.     Vector3 destination;
    12.     RaycastHit hit;
    13.     public float thrust = 1f;
    14.     Rigidbody rg;
    15.     Vector3 direction;
    16.     Ray ray;
    17.    
    18.  
    19.     void Start()
    20.     {
    21.     fromPosition = transform.position;
    22.     // Debug.Log("Position at start: " + _marker);
    23.     }
    24.  
    25.     void FixedUpdate()
    26.     {
    27.         HitCheck();
    28.  
    29.     }
    30.  
    31.     private void HitCheck()
    32.     {
    33.         destination = transform.position;
    34.         toPosition = transform.position;
    35.         direction = toPosition - fromPosition;
    36.         int layerMask = 1 << 8;
    37.         layerMask = ~layerMask;
    38.        
    39.         float dist = Vector3.Distance(transform.position, fromPosition);
    40.  
    41.         if (Physics.Raycast(origin: transform.position, direction: direction, hitInfo: out hit, .5f, layerMask: layerMask))
    42.         {
    43.            
    44.             Debug.Log("hit " + hit.collider.gameObject.name, hit.collider.gameObject);
    45.            if(hit.collider.gameObject.GetComponent<Rigidbody>() !=null)
    46.            {
    47.                rg = hit.collider.gameObject.GetComponent<Rigidbody>();
    48.                rg.AddForce(Vector3.forward * thrust);
    49.            }
    50.         }
    51.             Debug.DrawLine(fromPosition, toPosition, Color.white, 1f);
    52.  
    53.             fromPosition = toPosition;
    54.      
    55.     }
    56. }
    57.  
    58.  
     
  48. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,131
    Hey, thanks for the purchases!

    Please check out the "Puppet Raycast Hit" demo and RaycastShooter.cs on the camera there. Should be exactly what you need.
    If you just add force, that will be zeroed out by the pinning forces that keep the puppet pinned to it's animation frame by frame and it will have almost no effect. Need to do it like in the RaycastShooter script.

    Cheers,
    Pärtel
     
  49. Arlatan

    Arlatan

    Joined:
    Jun 23, 2020
    Posts:
    4
    Ah! It was right there the whole time!

    Thank you so much. It works! Time to 5 star that product!

    Cheers,
    Arlatan
     
    MostHated and Partel-Lang like this.
  50. MetalDonut

    MetalDonut

    Joined:
    Feb 7, 2016
    Posts:
    119
    Hey - This looks great SOME of the time! But sometimes the character doesn't ragdoll at all when using this method. Are there other settings I need to ensure are in place when changing state to unpinned like this?
     
unityunity