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

Using Animator.Play() to sample bone transform at specific state time

Discussion in 'Editor & General Support' started by mwk888, Mar 12, 2014.

  1. mwk888


    Jan 26, 2014
    I have not found a way to find a bone position for an Animator at a specific state time. I tried Animator.Play() like this:

    Code (csharp):
    1. void Start() {
    2.     const int BASE_LAYER = 0;
    4.     Animator animator = GetComponent<Animator>();
    5.     // The default initial right hand position
    6.     Transform rightHandPosition1 = animator.GetBoneTransform(HumanBodyBones.RightHand);
    8.     // Get right hand position 90% of way through the Jump Forward state DOES NOT WORK same as above
    9.     animator.Play(stateJumpForwardHash, BASE_LAYER, 0.9f);
    10.     Transform rightHandPosition2 = animator.GetBoneTransform(HumanBodyBones.RightHand);
    11. }
    That does not work because the Play() call seems to just queue the new state to be played in the next update; I need to advance the animation state immediately so I can read back the bone value.

    I think this is possible for the legacy Animation e.g. this post but I'm stumped on how to do it for an Animator.

    Any suggestions appreciated!
    Last edited: Mar 12, 2014