Search Unity

How am I supposed to make animation offsets in Unity?

Discussion in 'Animation' started by RedMattis, Mar 23, 2020.

  1. RedMattis

    RedMattis

    Joined:
    Apr 18, 2015
    Posts:
    33
    I've made an idle animation of a character swinging their arms. Since the lower arm would lag after the upper arm, and the hand in turn lags after the lower arm I've moved those keyframes backwards. So far so good.

    The issue is that I can't figure out how to tell Unity that I only want the animation to play from 0.08 to 1.08, which is the actual cycle. The other keyframes are just there to make sure the curves exit/enter at the right angles.

    This feels like something which should be trivial, so I must be missing something, but I've been spending a full day trying to figure this out without success, so I figured I'd ask here.

    (The only workable thing I've managed to do was hax something with transition times in "Animator", but I can't imagine that is the correct way to to do this.)
     

    Attached Files:

  2. DARTHMAYDAR11

    DARTHMAYDAR11

    Joined:
    Sep 30, 2015
    Posts:
    8
    1. var anim : AnimationState;
    2. var endAnimationAtTime : float;
    3. function PlayAnimation(nameOfAnimation, startTime, endTime) {
    4. anim = animation[nameOfAnimation];
    5. anim.time = startTime;
    6. anim.weight = 1;
    7. anim.enabled = true;
    8. endAnimationAtTime = endTime
    9. }
    10. function Update() {
    11. if(anim && anim.enabled && anim.time >= endAnimationAtTime)
    12. anim.enabled = false;
    13. }
    Found this from an older thread food for thought
     
  3. RedMattis

    RedMattis

    Joined:
    Apr 18, 2015
    Posts:
    33
    I mean, writing a script could certainly solve it, but that seems like working against Unity (creating a hack) rather than using their intended workflow. Whatever the intended workflow is in this case... :confused: