Search Unity

Animator.SetBoneLocalRotation - clarification needed

Discussion in 'Animation' started by PhilippG, Feb 3, 2016.

  1. PhilippG

    PhilippG

    Joined:
    Jan 7, 2014
    Posts:
    257
    Hello!

    I need some advice/clarification concerning Animator.SetBoneLocalRotation.

    I am adding a offset on the localrotation of the Upperarms on IKCallback,
    like so:
    rArm = Animator.GetBoneTransform(HumanBodyBones.RightUpperArm);
    Animator.SetBoneLocalRotation(HumanBodyBones.RightUpperArm, offset * rArm.localRotation);

    Now I figured that even without the offset, as soon as I call:
    Animator.SetBoneLocalRotation(HumanBodyBones.RightUpperArm, rArm.localRotation);
    the rotation does change a few degrees.

    Thats a problem because that is messing up some animations that rely on the arms rotations to be exact.
    If I just stop calling SetBoneLocalRotation the arm snaps into the right position, but I need to have it blend seamlessly.

    My question is:
    What parameter would I need so the rotation is not changed at all?
    Or when/on which layer, if it is a timing issue?
     
  2. lengmc

    lengmc

    Joined:
    Apr 10, 2019
    Posts:
    3
    Hi, did you find a solution? I'm facing exactly the same problem :(
     
    Malbers likes this.
  3. lengmc

    lengmc

    Joined:
    Apr 10, 2019
    Posts:
    3
    I tried to set UpperArm&LowerArm&Hand at the same time and it looks better but still have a slightly different rotation.

    animator.SetBoneLocalRotation(HumanBodyBones.LeftUpperArm, animator.GetBoneTransform(HumanBodyBones.LeftUpperArm).localRotation);

    animator.SetBoneLocalRotation(HumanBodyBones.LeftLowerArm, animator.GetBoneTransform(HumanBodyBones.LeftLowerArm).localRotation);

    animator.SetBoneLocalRotation(HumanBodyBones.LeftHand, animator.GetBoneTransform(HumanBodyBones.LeftHand).localRotation);
     
  4. lengmc

    lengmc

    Joined:
    Apr 10, 2019
    Posts:
    3
    For those are facing this, I achieved my goal by using this instead:

    void LateUpdate()
    {
    animator.GetBoneTransform(HumanBodyBones.LeftHand).localRotation *= someOffsetQuaternion;
    }

    When offsetQuaternion is totally 0, the LeftHand will stay perfectly where it should be.
     
  5. ChrisCoool

    ChrisCoool

    Joined:
    Jul 3, 2017
    Posts:
    14
    Hello! I am facing the same issue. Did you fix that? Thanks!!