Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

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:
    85
    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
     
  3. korzen303

    korzen303

    Joined:
    Oct 2, 2012
    Posts:
    224
    Hi, I have just come across same issue, Getting and Setting the same pose right after moves the character. In my case is the hip joint which gets translated.

    Can anyone from Unity explain this behaviour? Thanks