Search Unity

GetHumanPose and SetHumanPose in Update

Discussion in 'Animation' started by fmacro, Aug 13, 2018.

  1. fmacro

    fmacro

    Joined:
    Mar 24, 2017
    Posts:
    4
    I'm developing bone constraint system for Unity Mecanim.
    However, I had a trouble.
    I used HumanPoseHandler.GetHumanPose and HumanPoseHandler.SetHumanPose in Update method.
    Then, character's position was changed when character's initial position was not (0, 0, 0);

    This is my code.
    Code (CSharp):
    1. void Awake()
    2.     {
    3.         if (animator == null)
    4.         {
    5.             Destroy(this);
    6.         }
    7.         poseHandler = new HumanPoseHandler(animator.avatar, animator.transform);
    8.     }
    9.  
    10.     void LateUpdate()
    11.     {
    12.         poseHandler.GetHumanPose(ref pose);
    13.         pose.muscles[35] = x;
    14.         poseHandler.SetHumanPose(ref pose);      
    15.     }
     
  2. JonBanana

    JonBanana

    Joined:
    Feb 5, 2014
    Posts:
    81
    I got the same trouble 3 year after ...

    this code made the character move for no any reason

    Code (CSharp):
    1. poseHandler.GetHumanPose(ref pose);
    2. poseHandler.SetHumanPose(ref pose);  
    I have to manage the position by myself to fix the trouble
     
unityunity