Search Unity

  1. Full schedule for #UniteBerlin is now available! Featuring talks on our roadmap, hands-on labs and much more! Check it out!
    Dismiss Notice
  2. Unity 2018.1 has arrived! Read about it here
    Dismiss Notice
  3. Scriptable Render Pipeline improvements, Texture Mipmap Streaming, and more! Check out what we have in store for you in the 2018.2 Beta.
    Dismiss Notice
  4. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  5. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    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:
    1,626
    Hey,
    Nice job mate, thanks for sharing the demo!

    Hey,
    Yeah, I have GenericRagdollCreator in my todo list, but not sure when it will be done, got tons of other stuff there too.

    It would be best to create everything via code, if you are interested in maximum freedom of model replacement. It's not just a good idea with PuppetMaster, its a good idea with everything else too. Please take a look at the "Create Ragdolls In Runtime" and "Create Puppets In Runtime" demos to get started. BehaviourPuppet and BehaviourFall you can just instantiate from a prefab and parent to the "Behaviours" gameobject. PuppetMaster also has the "Humanoid Config" option that allow you to use a single PuppetMaster settings configuration file for multiple characters. See the "Humanoid Config" demo about that.

    Hey,
    That's in my todo list to take a look at, can't give you an estimation at this time though, not sure about all the technical limitations to that yet. Could you tell me more about the flying off glitches you are seeing?

    Best,
    Pärtel
     
  2. Useless-Media

    Useless-Media

    Joined:
    Apr 19, 2015
    Posts:
    91
    Hey,

    I have take a look at the AimIK demo you made with puppet master and final ik.
    Its working perfect in your demo but after i made it exactly the same like you did with my puppet then i have some strange results.

    I found out there is something wrong with my setup with this code
    Code (csharp):
    1.  
    2. void OnPuppetMasterRead()
    3.         {
    4.             if ( m_AmingStart )
    5.             {
    6.                 // This enables for using recoil, reload and gesture animations without weighing out AimIK.
    7.                 m_AimIK.solver.axis = m_AimIK.solver.transform.InverseTransformVector( m_Animator.transform.rotation * AnimatedAimingDirectionOffset );
    8.             }
    9.         }
    10.  
    I have the AimIK component on the same GameObject like the Animator.

    It looks like the aim gets multiplied and is increasing by angle.
    AimToMuch.gif
    I just Aim a little up and the character overdo the Aim.

    When i comment the code out everything work except the character does not Aim exactly to to the Target which depends on the AimIK Axis which i want modifier to Aim exactly to the target

    The question is how do i match the axis exactly to the Target?

    I think i just did it.

    Code (csharp):
    1.  
    2. // GET THE PROP
    3.                 var prop = m_PuppetMaster.muscles.ToList().Find( x => x.props.group == Muscle.Group.Prop );
    4.  
    5.                 //// This enables for using recoil, reload and gesture animations without weighing out AimIK.
    6.                 m_AimIK.solver.axis = m_AimIK.solver.transform.InverseTransformVector( prop.target.rotation * AnimatedAimingDirectionOffset );
    I just need to get the weapon itself, so simple





    EDIT: Yes its working but i still need to offset the axis.

    How can i change the Axis in this way that he automatically find the value to the Target?
    I have calculated the wanted Rotation from the Prop to the Target, so basically i need to convert the those Rotation to a Axis Rotation.
    I already try out Quaternion.ToAngleAxis but maybe wrong.

    Please guide me, i have the Rotation of the Prop, the Wanted Rotation and i think with this 2 things the relative rotation axis is possible.
     
    Last edited: May 19, 2018
  3. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,626
    Hey,
    Not entirely sure I understand what you are trying to do, but if you have calculated the offset you need for accuracy, you can apply it once to the AnimatedAimingDirectionOffset like so:
    Code (CSharp):
    1. AnimatedAimingDirectionOffset = calculatedRotation * AnimatedAimingDirectionOffset;
     
    Useless-Media likes this.
  4. somosky

    somosky

    Joined:
    Feb 15, 2014
    Posts:
    67
    Hi I am having a few issues adding Puppet Master to a multiplayer game.

    It's a first person shooter game so I've added in functionality to my raycastfire script to check for the correct PuppetMaster components and it works fine with in a single player situation. The issue is when I build the game. This works fine on the Host Computer but when the clients shoot a PuppetMaster object I get a NullReferenceError for this line of code

    var broadcaster = obj.GetComponent<Collider>().attachedRigidbody.GetComponent<MuscleCollisionBroadcaster>();

    Below I've attached the part of the script that has to deal with this Function not working. Also I've noticed that the Puppet detaches from the Root gameobject upon the scene starting. Does the detached Puppet Master gameobject need to have a network identity on it to work properly. I've tried to add a network identity to it and it didn't fix my issue but it also didn't seem to have any negative effects. Thanks alot.

    void firebullet()
    {
    Vector3 fwrd = FPCamera.transform.forward;
    Vector3 camUp = FPCamera.transform.up;
    Vector3 camRight = FPCamera.transform.right;

    Vector3 wantedvector = fwrd;
    wantedvector += Random.Range( -inaccuracy, inaccuracy ) * camUp + Random.Range( -inaccuracy, inaccuracy ) * camRight;
    Ray ray = new Ray (FPCamera.transform.position, wantedvector);
    RaycastHit hit = new RaycastHit();

    if (Physics.Raycast(ray,out hit, range,mask))
    {
    Vector3 HitPoint = hit.point;
    GameObject decal;
    GameObject line;
    line = Instantiate (lineprefab, transform.position, transform.rotation) as GameObject;
    LineRenderer linerender = line.GetComponent<LineRenderer> ();
    linerender.SetPosition (0, currentmuzzle.transform.position);
    linerender.SetPosition (1, hit.point);
    }
    if (hit.transform.tag == "water")
    {
    Debug.Log("Hit PuppetMaster Object");
    CmdPuppetMasterDealDamage(hit.transform.gameObject, HitPoint, fwrd, ray);
    }

    [Command]
    void CmdPuppetMasterDealDamage(GameObject obj, Vector3 HitPoint, Vector3 fwrd, Ray ray)
    {
    GameObject HitEffect = Instantiate(impactnormal[CurrentHitEffectInt], HitPoint, transform.rotation);
    NetworkServer.Spawn(HitEffect);
    var broadcaster = obj.GetComponent<Collider>().attachedRigidbody.GetComponent<MuscleCollisionBroadcaster>();
    if (broadcaster != null)
    {
    broadcaster.Hit(unpin, ray.direction * force, HitPoint);
    }
    else
    {
    Debug.Log("None Found");
    }
    }
     
  5. Ohhhglasses

    Ohhhglasses

    Joined:
    Jan 15, 2015
    Posts:
    2
    I'm wondering if there are some suggested practices for a problem I'm having with Puppet Master. I acknowledge that I may be doing something wrong. My question is around collision events.

    I have my main bone heirarchy which is animated (and also contains all game components such as hp for instance, which is stored on each body part in this game.)
    I've created my puppet master heirarchy using the ragdoll creator and everything is working just fine. However, I don't want to create even more colliders and rigidbodies on my main bone heirarchy for performance reasons. Is there a suggested approach so that I can use the puppet master heirarchy's colliders alone and detect collisions and maybe pass them over to the main bone heirarchy somehow? Right now, I intend to create a mapping between the puppet master's bones so that I can send the events on over. I just wonder if there is a standard approach to this problem, potentially a more lightweight approach?
     
  6. Useless-Media

    Useless-Media

    Joined:
    Apr 19, 2015
    Posts:
    91
    I using the Collision Events on BehaviourPuppet:

    Code (csharp):
    1.  
    2. private void Start()
    3.         {
    4.             var puppet = this.GetComponentInChildren<BehaviourPuppet>();
    5.  
    6.             puppet.OnPreMuscleCollision += OnMuscleCollision;
    7.             puppet.OnPreMuscleCollisionExit += OnMuscleCollisionExit;
    8.  
    9.             //puppet.OnMuscleHit +=
    10.             //puppet.OnCollisionImpulse +=
    11.         }
    12.  
    13. public void OnMuscleCollision( MuscleCollision m ) {
    14.  
    15.         }
    16. public void OnMuscleCollisionExit( MuscleCollision m ) {
    17.  
    18.         }
    19.  
    Just Create a List of your collision class/struct and add and remove the items in the list in this 2 events
     
    Partel-Lang likes this.
  7. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,626
    Hey,
    If you get a NullReferenceExeption on this line, it's either that the object that hits doesn't have a collider on it (maybe it's on it's child?) or there's no Rigidbody on it.

    The networked PuppetMaster is supposed to detach, that is because it only needs to be moved by physical forces, not by you moving the character controller. As the root needs to have the NeworkView, normal PuppetMaster hierarchy can't work, so it detaches.

    Hey,
    As Useless-Media already kindly suggested.

    Cheers,
    Pärtel
     
  8. somosky

    somosky

    Joined:
    Feb 15, 2014
    Posts:
    67

    So after doing some testing last night the issue I am having is that I raycast and hit the body part of the Puppet. I've debug.logged the name of the body part to make sure that's working. That Puppet as you mentioned is unparented from the game object. So it no longer has a Network ID so through my Cmd function I can't alter it .

    I wrote a new function that passes a reference to the rag doll and the character as well as a string that names which body part was hit. That is almost working but what happens is shot from the client the Puppet slightly moves and if you shoot from the server the Puppet gets the correct amount of force added to it and acts correctly. It's almost as the force gets added by the client but the servers puppet moves it back immediately negating the force added.

    All of your demo scenes are great and have been a great help but since the networking one is using a object to simulate force instead of a raycast I'm really struggling with this part.
     
  9. keifyb

    keifyb

    Joined:
    Feb 12, 2016
    Posts:
    61
    im trying follow the tpc integration tutorial to use with the unet demo with no joy. The guy keeps flying off to the sky if i touch a damage object. any updates on this?
    ive also tried it with unitz unet but no joy there also. im really struggling to understand how to use it in a multiplayer environment.