Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

2D Sprites - change to new animation's frame based on previous animation's frame

Discussion in '2D' started by UnityBandi, May 27, 2015.

  1. UnityBandi

    UnityBandi

    Joined:
    May 27, 2015
    Posts:
    2
    Hello!

    I'm having some trouble to sync different animations during Animator state change:

    Player controlled character has two states: running and dodging. Each state has an animation assigned to it, and each animation consists of 8 frames. By default player is in running state (playing run animation), and after pressing a button he starts to dodge.

    Let's say the player interrupted run animation at frame number 5. At this moment I want to start dodge animation in frame 5, but it always starts at frame 1.

    Is there a way to solve this problem?
     
  2. ColossalPaul

    ColossalPaul

    Unity Technologies

    Joined:
    May 1, 2013
    Posts:
    174
    Hi,

    Hard to diagnose without a repro case. If you believe it is a bug, please file it then the guys can take a closer look.
     
  3. rakkarage

    rakkarage

    Joined:
    Feb 3, 2014
    Posts:
    683
  4. UnityBandi

    UnityBandi

    Joined:
    May 27, 2015
    Posts:
    2
    Thanks for the tips, I'll investigate them.

    For now I solved this problem this way:

    float time = animStateInfo.normalizedTime;
    anim.Play("HeroDodge", 0, time);

    Do you know any drawback of this kind of solution?