Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice
  2. Read here for Unity's latest plans on OpenXR.
    Dismiss Notice

Help Wanted How to know where(Vector3) the transform will be at the end of the animation?

Discussion in 'Unity MARS' started by Milionario, Oct 21, 2020.

  1. Milionario

    Milionario

    Joined:
    Feb 21, 2014
    Posts:
    94
    So I want to be able to know before playing an animation that applies rootmotion, where will my character be at the end of it?

    EDIT:
    Just seen I created this in the wrong forum. Could somebody move it to "Animation"?
     
    Last edited: Oct 22, 2020
  2. polemical

    polemical

    Joined:
    Jun 17, 2019
    Posts:
    1,069
    You could try something like this (untested)..
    Code (CSharp):
    1. public Animator anim;
    2. public Transform animRoot;
    3. // [...]
    4. anim.Play(clip, layer, 1); // set it to the end
    5. Vector3 positionAtEnd = animRoot.position; // get the position
    6. // todo: whatever you want, based on positionAtEnd
    7. anim.Play(clip, layer, 0); // set it back to the beginning
    8. // ..and if you don't want the animation to actually play right away, uncomment:
    9. // anim.StopPlayback();
     
  3. Milionario

    Milionario

    Joined:
    Feb 21, 2014
    Posts:
    94
    I already tried that with animancer(similar to animator but more flexible and with no animator graph)
    but the animation transform position only seems to take effect on the next frame
     
unityunity