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
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

PuppetMaster - Advanced Character Physics Tool [RELEASED]

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

  1. ColtonKadlecik_VitruviusVR

    ColtonKadlecik_VitruviusVR

    Joined:
    Nov 27, 2015
    Posts:
    169
    Thanks for the reply, this does work if the delta is divided by fixed delta time.

    Another issue I am having is random (very infrequently, but still noticeable) stuttering of the players body when moving. Correct me if I am wrong but I believe this is caused by VRIK updating in update or late update whereas my character controller and PuppetMaster are updated in Fixed Update. I think the stutter is caused when a frame is dropped and update & fixed update get out of sync. This is easily fixable by parenting the body (including VRIK and PM) onto the character controller. I assume this is a bad idea because none of your examples were setup this way. Will this setup cause incorrect physics simulation? If this is indeed bad, can I manually update VRIK and PM in fixed update? Do I need to call anything other than update on those 2 components?

    Cheers,
    Colton

    P.S Sorry for the loaded question

    EDIT: Also wondering if you offer any paid services (i.e. one on one chats etc.)?
     
    Last edited: Feb 13, 2020
  2. Redux

    Redux

    Joined:
    Nov 10, 2011
    Posts:
    133
    @Partel-Lang Does that "other method" also preserve asset/prefab linkages? One problem with how things work atm is that the setup process breaks links to original assets/prefabs on rebuild as it recreates everything. I'm not sure I follow the alternative setup either. Does this mean the animated model in the puppetmaster hierarchy after puppetmaster setup can be a different object than the rebuilt one?

    Can you do some screencaps of this in action so I can follow the steps? Thanks m8.
     
  3. thestroyer_

    thestroyer_

    Joined:
    Oct 12, 2015
    Posts:
    9
    Hi! I am having some issues changing the puppet position instantly. I tried to use the method Teleport() of the puppet master, but it seems it doesn't work. When using the method you can see the puppet interpolating from his last position to the one that I told him, but when it finishes to interpolate, it keeps the inertia from the interpolation and unpins from the puppet master (even with pin weight and muscle weight at maximum).

    Mention that I have no behaviours attached to the PuppetMaster.
     
  4. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,060
    Hey,
    I never tried BehaviourDesigner myself so I'm not sure how to fix it. I think it might have to do with that (SharedFloat) thing, probably a global variable used for all instances. Maybe if you asked BehaviourDesigner guys, they probably will be able to help you.

    Hey,
    To make PM/VRIK update in FixedUpdate, all you have to do is set Animator to "Animate Physics" mode.
    It is OK to parent the character to the controller, just make sure the controller is not moved while behaviourPuppet.state != BehaviourPuppet.State.Puppet;

    I don't normally do paid support just because of the extra billing and accounting headache, but if you wanna add me to Discord, please PM me.

    Hey,
    Yes, the other method preserves all your linkages and it doesn't have to unpack the prefab either. All it does to the original is change it's transform.parent.

    Made a quick video for you showing how it should be done.

    Hey,
    Are you sure you are running the latest PM because I though I had all those problems fixed with the last version.
    The latest is 0.9, you can check it from the "PuppetMaster ReadMe" file under Plugins/RootMotion/PuppetMaster.

    Best,
    Pärtel
     
  5. thestroyer_

    thestroyer_

    Joined:
    Oct 12, 2015
    Posts:
    9
    I am running the version 0.9.

    I have just found the issue. It seems that having the Pin Pow value high was the problem. Setting it to a lower value seems to fix the problem I had.

    Thank you and sorry for the inconvenience!
     
  6. AhJun

    AhJun

    Joined:
    Dec 30, 2019
    Posts:
    12
    Not sure if it has been asked before, but how do I make a prop affect the rig? For example, using a weapon to hit/block a prop that the rig is holding. Would it be hacky to just change the side of the hand collider and treat the prop as a hand?

    EDIT: nm, the Prop example has good info/comments about it!
     
    Last edited: Feb 21, 2020
  7. Redux

    Redux

    Joined:
    Nov 10, 2011
    Posts:
    133
    @Partel-Lang Very useful, thanks. I was wondering if I can make the puppet sync immediately to the animated model transforms on demand? I have need for such a use case.
     
  8. Sun-Pengfei

    Sun-Pengfei

    Joined:
    Nov 12, 2015
    Posts:
    31
    @Partel-Lang Hi Pärtel, really love Final IK and PuppetMaster. I have some inquiries regarding them. I've sent email to CONTACT@ROOT-MOTION.COM, but got no reply yet. Sorry to push this way, but my project is stuck right now. Could you check it out please? Many thanks!
     
  9. flow-

    flow-

    Joined:
    Apr 19, 2015
    Posts:
    164
    Hey,
    Currently, I experience an issue with my setup, not really sure who to ask because it's also controller related, however, I set up the Props on my character and for some reason the prop makes the controller stuck.

    But I don't think it's depending on the controller force I think it has something to do with the physics because using a non-friction physics material is minimizing the issue so it only occurs sometimes.

    Here a small video of the issue: As you can see make the sword stuck the controller


    What I did and I think that's a valid point that I use the Unmapped Mode on the Behaviour Puppet but also release the Joint angular motion to free after the prop is equipped.

    But after all, I have no idea what's can cause this, maybe I'm lucky and get a reply :)

    EDIT: Figured out it has something to do that I changed like mentioned above the Join angular motion to free.... without it's gone but brings another issue as I want to have a free motion for the props with maybe just a tiny bit of control, I try to tweak the group values but did not come to a specific value where I archived this free behaviour... also I use the Unmapped state so I guess the props also stop using physics when there is no collision which is something I don't want because they should move free when the character is moving


    EDIT Again:
    Well I figured it out, Puppetmaster works fine with the Joint angular motion set to free, the issue was that I did not notice a collider in the Prop Target Hierarchy which made the controller stuck but by disabling the collider all works fine :)
     
    Last edited: Feb 26, 2020
  10. alsomitra

    alsomitra

    Joined:
    Aug 31, 2017
    Posts:
    21
    Hey,

    I want to make the kick and punch characters temporarily invincible.
    It is strange that an attacker falls into a collision.
    Which parameters need to be adjusted to make the character invincible?
    If someone asked the same question in the past, sorry.

    Thank you very much
     
  11. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    181
    Putting my question here as your website Q&A is getting spammed to death....

    I am 99% sure I saw a video of yours where you can increased the size of a puppets components through a slider e.g. make the hands larger. I can not find the video, which means its my imagination or maybe in final ik? Can you tell me if this exists? If yes, where is the video or how to.

    Thanks.
     
  12. songjiekun

    songjiekun

    Joined:
    Jan 21, 2017
    Posts:
    26
    @Partel-Lang

    hello,
    one question.
    how to add or remove Behaviours from puppetmaster in runtime? for example i want to add "behaviourpuppet" at somepoint of time in my game logic. and remove or disable this behaviourpuppet (or other behaviour) at some other point of time in my game logic.
    when i disable these behaviours, i want they have no any impact on my game logic. i have checked the code. i found if i disable the behaviourpuppet script. most of the logic will disabled. however some logic like collision will still be effective.
    how to disable then 100% in runtime?

    thanks.
     
    gliealonso likes this.
  13. Milionario

    Milionario

    Joined:
    Feb 21, 2014
    Posts:
    23
    Is the stagger behaviour only available on Final IK?
     
  14. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    537
    Hello Partel and nice people,

    i have a question about puppetmaster events. How should i go to achieve the following. If a character looses balance, since it is a turn based game, i want it to stay in the ground until the next turn. I have tried sending the kill function when the puppet is knocked out, and set the state.alive, at the turn beginning. It could work like that, but ideally the puppet should go to a lay down animation after loose balance and then i call the getup function in the next turn, which now is automatically called by the behavior i think.
    Any recommendation?

    thanks a lot and best regards!
     
  15. Milionario

    Milionario

    Joined:
    Feb 21, 2014
    Posts:
    23
  16. songjiekun

    songjiekun

    Joined:
    Jan 21, 2017
    Posts:
    26
    @Partel-Lang
    one more question.

    i have seen there are two public function in puppetmaster.OnPostSimulate and OnPreSimulate. when to call these functions? can we use these function if we want to manually map bone to the muscle before lateupdate (i believe lateupdate or fixedupdate is the place where map happens in puppetmaster code)?
     
  17. alexkarak

    alexkarak

    Joined:
    Feb 7, 2018
    Posts:
    24
    Hey Partel I am using this script to add damage to my enemys AI.But currently the damage is applied even if the Ai collides with the envirorment or with each other (and the damage they take is too little ...most of the times even though they ve been hit they take no damage)....and i want them mainly to take damage only from my Player if possible..and to make its hit apply more damage (if i can tweak something in puppet behaviour of my ai or my player to achieve "better or stronger hits")
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using RootMotion.Dynamics;
    5. using BehaviorDesigner.Runtime;
    6.  
    7. public class Cop : MonoBehaviour
    8. {
    9.     public BehaviourPuppet puppet;
    10.     public BehaviorTree behaviorTree;
    11.     public SharedFloat health;
    12.     public HealthBar healthbar;
    13.     public SharedBool Hit;
    14.    
    15.     void Start()
    16.     {
    17.        
    18.         puppet.OnCollisionImpulse += OnCollisionImpulse;
    19.         health = (SharedFloat)behaviorTree.GetVariable("health");
    20.         healthbar.SetMaxHealth(health);
    21.         Hit = (SharedBool)behaviorTree.GetVariable("TakeDamage");
    22.  
    23.     }
    24.  
    25.     private void OnCollisionImpulse(MuscleCollision m, float impulse)
    26.     {
    27.  
    28.         health.Value -= impulse/100;
    29.         behaviorTree.SetVariableValue("health", health);
    30.         healthbar.SetHealth(health.Value);
    31.         Hit.Value = true;
    32.        
    33.         if (health.Value <= 0f)
    34.  
    35.         {
    36.             behaviorTree.SetVariableValue("health", 0f);
    37.             puppet.puppetMaster.Kill();
    38.         }
    39.     }
    40.    
    41.    
    42.  
    43. }
    44.            
    45.    
    46.  
     
  18. gliealonso

    gliealonso

    Joined:
    Oct 21, 2018
    Posts:
    57
    Not sure if I understood you. But I believe your character is losing balance when he's punching or kicking, is that correct?

    If that's the case, tryi setting the "Knockout Out Distance" to 10.

    You can leave it fixed on the public field or change whenever you want through code
     

    Attached Files:

    Partel-Lang likes this.
  19. gliealonso

    gliealonso

    Joined:
    Oct 21, 2018
    Posts:
    57
    Hi there,

    There is a scene called "Scaling" =)
     
    nobluff67 and Partel-Lang like this.
  20. gliealonso

    gliealonso

    Joined:
    Oct 21, 2018
    Posts:
    57
    Hi,

    Do you want to do that because you want the character not to fall in certain moments?

    If that's the case, what you can do is, increase the Collision Resistance to a very high number, such as 9999999, and also set the Knock Out Distance to 10, which you can also do by code.

    I attached an example. If that's not the case, then only Partel can help you xD
     

    Attached Files:

    Partel-Lang likes this.
  21. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,060
    Hi guys, very sorry for the long wait, was out of town on vacation last week.

    Code (CSharp):
    1. foreach (Muscle m in puppetMaster.muscles)
    2.         {
    3.             m.MoveToTarget();
    4.             m.ClearVelocities();
    5.         }
    Hey,
    Sorry for the way, was on vacation last week, will reply to you ASAP!

    Hey,

    You should use the Boosters. Declare a public Booster booster; fill it out in the editor. It can be used to give temporary immunity and/or impulse multiplier to the puppet. To use it, call booster.Boost(behaviourPuppet); The boosting effect will fade out over time , defined by Boost Falloff in BehaviourPuppet. Value of 1 means the effect will be gone in 1 second.

    Hey,
    Yeah, I'm deleting spam almost every day, but was on vacation last week, sorry about that.
    Please check out the "Scaling" demo in PM, I think that's what you saw.

    Hey,
    If you're looking to optimize puppets while they need no physics, you should set puppetMaster.mode to puppetMaster.Mode.Disabled. That deactivates the ragdoll and the behaviours will not run at all and you will not get any collisions processed.

    But if you did this:
    Code (CSharp):
    1.  foreach (Muscle m in puppetMaster.muscles)
    2.         {
    3.             m.broadcaster.enabled = false;
    4.         }
    That would prevent collision events from being sent to BehaviourPuppet.

    Hey,
    Looking at that gif, could try going to BehaviourBipedStagger and increase maintainRotationWeight to something like 0.5f on lines 262 and 263 to reduce the tip toeing effect.

    Hey,
    OnPre/PostSimulate are there for projects that need to have Physics.autoSimulation disabled. Then PuppetMaster can be updated manually like this:

    Code (CSharp):
    1. foreach (PuppetMaster puppetMaster in puppetMasters)
    2.             {
    3.                 puppetMaster.OnPreSimulate(deltaTime);
    4.             }
    5.  
    6.             Physics.Simulate(deltaTime);
    7.  
    8.             foreach (PuppetMaster puppetMaster in puppetMasters)
    9.             {
    10.                 puppetMaster.OnPostSimulate();
    11.             }
    Mapping happens in LateUpdate when your Animator is in Normal mode and in FixedUpdate when in AnimatePhysics mode.

    Why exactly do you need to map before LateUpdate? If you did it in Update, your mapping would happen before animation so that would just overwrite it.

    Hey,
    You should check for the layer of the colliding object (m.collision.collider.layer), to see if it was another puppet or something else and multiply damage accordingly. Could also check for if (m.collision.collider.attachRigidbody == null || m.collision.collider.attachedRigidbody.isKinematic) to identify collisions with static objects.

    Cheers,
    Pärtel
     
  22. alexkarak

    alexkarak

    Joined:
    Feb 7, 2018
    Posts:
    24
    And how do I prevent collisions with other AI puppets since both AI and the player have the same layers?
     
  23. songjiekun

    songjiekun

    Joined:
    Jan 21, 2017
    Posts:
    26
    @Partel-Lang
    thank you.

    1. disable BehaviourPuppet
    i don't want to optimize puppets. i just want to temporarily disable it functions. i want temporarily use my only logic to handle some gameplay.
    so in order to 100% disable BehaviourPuppet, we should first disable BehaviourPuppet component, then disable broadcaster . if we want to reenable it, just enable BehaviourPuppet component and broadcaster, right?

    2. "Why exactly do you need to map before LateUpdate? "
    because i need to duplicate a puppetmaster at runtime. i found that after duplication. there is one frame, the puppet is fallback to it's origianl animation bones. so i think for that frame i need to manually do "map bone" and "move muscle". so i think PostSimulate is the right function to call,right?
     
  24. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    181
    Thanks! So not a video I saw, but a example scene.
     
  25. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,060
    Hey,
    You mean you want all your AI puppets to ignore collisions with each other but not the player?

    If so, you'll have to move the player to another layer and disable AI layer collisions with itself.

    1. OK, I see. Sorry, I didn't think about it at first because nobody has asked about it for years, but the intended way of handling custom puppet controlling logic would be to make a custom puppet behaviour.
    Check out BehaviourTemplate.cs. Make a new script MyBehaviour.cs that extends BehaviourBase. You can actually leave it empty like that if you don't want it to do anything. Make a new GameObject next to BehaviourPuppet and add MyBehaviour on that. The point is, to completely disable BehaviourPuppet, just call myBehaviour.Activate();
    Call behaviourPuppet.Activate() to resume to BehaviourPuppet.

    2. At which point in the update cycle are you creating the duplicate? Might just work if you do it from another point in time, like maybe use LateUpdate of a script that runs after PuppetMaster (Script Execution Order). Then your duplicate would be identical by rendering time and start performing on it's own the next frame.

    Cheers,
    Pärtel
     
  26. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    537
    You missed this one! ;)
     
  27. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,060
    Oh, sorry!
    Please just set behaviourPuppet.canGetUp to false and it will stay down.
     
    Danirey likes this.
  28. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    537
    So easy, as always!

    Thanks a lot!
     
  29. alsomitra

    alsomitra

    Joined:
    Aug 31, 2017
    Posts:
    21
    Stagger and Baker

    Hey,

    I set up Baker in Stagger,
    Then a strange animation was created.

    Is this combination bad?

    Thank you
     
  30. Milionario

    Milionario

    Joined:
    Feb 21, 2014
    Posts:
    23
    How to combine stagger with lookat without producing jittering effects?
     
  31. ColtonKadlecik_VitruviusVR

    ColtonKadlecik_VitruviusVR

    Joined:
    Nov 27, 2015
    Posts:
    169
    Hey @Partel-Lang,
    I'm working on picking up items in VR using your prop system. At first I tried creating a prop muscle in the editor and using that to attach items. This lead to the item flipping/rotating erratically when switching the item between the players hands as I had to create a different position & rotation offset so that item fits correctly in hand. Next I tried creating a new prop muscle each time the player wants to pick something up, which is created with a position and rotation offset (the item now always goes to local origin of the prop muscle). This fixes the spinning issue and looks great, but I was wondering if there was a more performant way of doing this? (i.e. creating/destroying muscles seems like a waste if I could just move it). Is there a way I can move the muscle when it is disconnected?

    Also, If I must create/destroy prop muscles during runtime, what is the correct way to clean up after a prop muscle? Currently I am listening for a disconnect event and then a remove event but this is leading to an index out of range exception.

    Thanks,
    Colton

    EDIT: I have created a dictionary that maps the prop to the muscle with the correct offsets so I do not re-create muscles that have already been created/destroyed in the past (creates a prop muscle pool), however, the system breaks down for some reason if I switch hands more than once (i.e. Interact with right hand, stop, interact with left hand, stop, I cannot interact again with the right prop muscle). Any idea why?
     
    Last edited: Mar 10, 2020
  32. stevenwanhk

    stevenwanhk

    Joined:
    Jul 20, 2016
    Posts:
    105
    Hi @Partel-Lang, haven't caught up this for a while. Is Puppet Master using Job system or similar technology to improve performance? We found that having around 20 puppet master units would be maximum a year ago.
     
  33. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,060
    Hey,
    Those pilots in the stagger demo have Animator on the parent gameobject of the actual avatar (Pilot) and apparently that is a problem for Baker (HumanPoseHandler uses the wrong root transform). You'll just have to copy the Animator, remove it and paste it on the Pilot gameobject, then it will work. Once the clip is produced, select it and set all "Based Upon"-s to "Original" and enable "Bake Into Pose" for "Root Transform Position (Y)".

    Hey,
    I tried adding LookAtIK to the character in Stagger demo, but didn't see any jitter. Can you tell me how to reproduce this problem?

    Hey,
    It would be best to find the problem that was causing the flipping issue so you would not have to use any workaround hacks. Would it be possible for you to send me some kind of a repro so I could figure this out?

    I don't think jobs help much with that as main performance culprit is still physics processing. I will try Unity Physics for DOTS once it has matured some.

    Cheers,
    Pärtel
     
  34. Partel-Lang

    Partel-Lang

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

    Because of all the frequent automated spam, notification issues and other limitations of the old RootMotion Q/A page, I am nuking that and moving over to https://rootmotion.freshdesk.com/support/home.

    It has FAQ, categorized forum and a ticketing system so hopefully that will improve the support experience for you guys!

    Cheers,
    Pärtel
     
  35. Milionario

    Milionario

    Joined:
    Feb 21, 2014
    Posts:
    23
    Is there a reason the character on the stagger demo has a mass of 1 for all of its rigidbodies?
     
  36. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,060
    The behaviour just looks better with uniform mass, but it's not a must.
     
  37. TimHogklint

    TimHogklint

    Joined:
    Nov 24, 2017
    Posts:
    1
    Speaking of which - have you tried using the stagger with some machine learning ? Sorry if this been asked a million times.
     
  38. IkaBika

    IkaBika

    Joined:
    Jul 23, 2013
    Posts:
    51
    Hi all, is there way to get feet placement callback events in PM?
     
  39. ColtonKadlecik_VitruviusVR

    ColtonKadlecik_VitruviusVR

    Joined:
    Nov 27, 2015
    Posts:
    169
    Hey @Partel-Lang,
    I am still having a tough time deciding if the prop system is the way to go for our VR implementation and I was wondering if you could weigh in on the decision? If you were going to implement picking up items in vr (using VRIK and PM), how would you do it? The props seem to work well except that sometimes they don't effect the hand enough and rotate away when being pushed into geometry, if there was a way increase the effect the prop has on the arm that would work. Conversely, if I just parent objects onto the hand, everything stays together because they share a rigid body, but they don't rotate off objects nicely and I'm not sure how physically accurate everything will be.
    Do you have any thoughts on how to achieve a happy medium between physically accurate and looking good?
    Cheers,
    Colton
     
  40. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,060
    Hey,
    I have thought about it, but haven't had the time to put in the effort to see what it actually takes yet. Should be possible to use ML with PuppetMaster though.

    Hey,
    What exactly do you mean? PuppetMaster has no idea if the puppet's feet are grounded or not, it doesn't need that information normally.

    Hey,
    Please try tweaking some values like "Unpin Parents" in the Group Overrides of BehaviourPuppet. For example if you have a group override for the Prop group and increase "Unpin Parents" for that group, that would make collisions with the prop loosen the hand muscle some more (as it is the parent of the prop).

    What exactly did you mean by "they don't rotate off objects nicely" when the object colliders are parented to the hand?

    Best,
    Pärtel
     
  41. Milionario

    Milionario

    Joined:
    Feb 21, 2014
    Posts:
    23
    How to turn the whole Pilot with LookAtIK on the Stagger demo? Meaning it should stagger towards the target?
     
  42. alsomitra

    alsomitra

    Joined:
    Aug 31, 2017
    Posts:
    21
    Hey,
    Sorry for the late reply.
    thank you for the advice.
    I will check.
     
  43. Milionario

    Milionario

    Joined:
    Feb 21, 2014
    Posts:
    23
    How can I make a puppet with stagger behaviour to mantain his forearm always pointing up?

    For example this is the pose I put him initially:


    But if he falls I want to MANTAIN the forearm pointing up(world Vector3.up), it points to where I left the pose which is normal I guess:


    I tried freezing the rotation on Y and Z, it works but then the staggering is somewhat 'supported' because of it and less natural, any other alternative?
     
  44. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,060
    Hey,
    It will stagger in the direction in which it is falling. So could try adding force to for example the spine rigidbody in the direction you want to push him.

    Hey,
    Please try this script:

    Code (CSharp):
    1. public PuppetMaster puppetMaster;
    2.  
    3.     private Muscle chestMuscle;
    4.     private Transform rightUpperArm;
    5.     private Transform rightForearm;
    6.     private Transform rightShoulder;
    7.     private Vector3 rightShoulderAxis;
    8.     private Vector3 rightUpperArmAxis;
    9.  
    10.     private void Start()
    11.     {
    12.         // Cache bones and muscles
    13.         chestMuscle = puppetMaster.muscles[puppetMaster.GetMuscleIndex(HumanBodyBones.Chest)];
    14.         rightUpperArm = puppetMaster.targetAnimator.GetBoneTransform(HumanBodyBones.RightUpperArm);
    15.         rightForearm = puppetMaster.targetAnimator.GetBoneTransform(HumanBodyBones.RightLowerArm);
    16.         rightShoulder = puppetMaster.targetAnimator.GetBoneTransform(HumanBodyBones.RightShoulder);
    17.  
    18.         // Get axes from shoulder and upper arm towards their next bones
    19.         rightShoulderAxis = Quaternion.Inverse(rightShoulder.rotation) * (rightUpperArm.position - rightShoulder.position);
    20.         rightUpperArmAxis = Quaternion.Inverse(rightUpperArm.rotation) * (rightForearm.position - rightUpperArm.position);
    21.  
    22.         // Register to get a call from PM each time before it reads the pose
    23.         puppetMaster.OnRead += OnPuppetMasterRead;
    24.     }
    25.  
    26.     void OnPuppetMasterRead()
    27.     {
    28.         // World space target direction
    29.         Vector3 worldDir = Vector3.up;
    30.  
    31.         // Convert world space to chest muscle space
    32.         Vector3 dir = chestMuscle.target.rotation * (Quaternion.Inverse(chestMuscle.transform.rotation) * worldDir);
    33.  
    34.         // Rotate shoulder and upper arm
    35.         rightShoulder.rotation = Quaternion.Slerp(Quaternion.identity, Quaternion.FromToRotation(rightShoulder.rotation * rightShoulderAxis, dir), 0.5f) * rightShoulder.rotation;
    36.         rightUpperArm.rotation = Quaternion.FromToRotation(rightUpperArm.rotation * rightUpperArmAxis, dir) * rightUpperArm.rotation;
    37.     }
    Best,
    Pärtel
     
  45. Milionario

    Milionario

    Joined:
    Feb 21, 2014
    Posts:
    23
    Hi Partel tahnks for your reply, in the first question I actually meant something a little different, at the moment I am adding forces to the character spine so it staggers in a direction but his 'rotation' stays the same, the LookAtIK only works with a head bone(obviously), I would like to make it twist around or atleast try to look at the direction it is moving, is that possible?

    And regarding the second script I am gonna try it out, does it need to derive from a specific class? Thank you!

    By the way I sent you a PM about something I found which I don't know if it was intended to work like that or not.
     
    Last edited: Mar 20, 2020
  46. NewMagic-Studio

    NewMagic-Studio

    Joined:
    Feb 25, 2015
    Posts:
    145
    I contacted you to your email many days ago and dont reply. I am using old prop system and my weapon props go through colliders, they dont work anymore, maybe the update made old system not work anymore? though the old scripts are still in the package. And the new system gives me errors, so doesnt work either, though in the examples scenes doesnt give any error. I am using it with vrik
    Prop colliders dont go through , just the mesh render of the model goes through
     
    Last edited: Mar 22, 2020
  47. NewMagic-Studio

    NewMagic-Studio

    Joined:
    Feb 25, 2015
    Posts:
    145
    Got to solve it, it was cause i had Muscle mapping weight to 0
     
  48. NewMagic-Studio

    NewMagic-Studio

    Joined:
    Feb 25, 2015
    Posts:
    145
    Now i got a problem i didnt have for some time, hands go up and sometimes i cant move it, maybe that is why i had Muscle mapping weight to 0, you can see it in the shadows the character make, left hand is up and i cant move it, and right hand just bends with elbow. I attach you the video in mail i sent you.
     
  49. Kagyu

    Kagyu

    Joined:
    Mar 5, 2016
    Posts:
    62
    Hi Partel,
    I like to change the siblings index of PuppetMaster transform after making my model to a puppet.
    For now I do not see any problem by changing the order of children but I would like to make sure this changing does not cause any issue in the future.
    Do you think changing siblings index is ok for the PuppetMaster plugin? PuppetMasterForumQuestion20200324.jpg
     
  50. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    2,060
    Hey,
    If you have spine bones assigned to LookAtIK, it should also rotate the spine. But you could just add rotation offset to the spine bones in LateUpdate or from PuppetMaster.OnRead to turn them left/right, like this:

    Code (CSharp):
    1. public Vector3 spineOffset;
    2.  
    3. void Start() {
    4. puppetMaster.OnRead += OnPuppetMasterRead;
    5. }
    6.  
    7. void OnPuppetMasterRead() {
    8. spine.localRotation *= Quaternion.Euler(spineOffset);
    9. }
    That script doesn't have to derive from anything other than MonoBehaviour.

    Hey,
    Just replied to your email.

    Hey,
    That is not a problem, don't worry about it.

    Best,
    Pärtel
     
unityunity