Search Unity

Having problems with manually animating the Animator, some frames happen twice

Discussion in 'Animation' started by MagicCancel, Feb 24, 2018.

  1. MagicCancel

    MagicCancel

    Joined:
    Jul 30, 2015
    Posts:
    25
    So, to give a little background, I am making a fighting game. As a part of that, I want to have ultra precise control over the frames of an attack. How many frames it will be in windup, how many frames it will be in the attack phase, how many frames it takes for the cooldown to occur.

    What I have done, based on a previous post, was turn off the Animator component, and in my code I have something like:

    FixedTimeStep = 1.0f/60.0f;
    anim.Update(FixedTimeStep);

    This seemed to be working fine, but as I was working on the part of my code that handles attack recognition I noticed something odd, an attack was lasting a frame longer than I set it up to. Specifically, the frame at 0:08 on the timeline (which has a sample rate of 60 by the way) was happening twice. When I put an attack to end n that frame starting from frame 0:05 it should last for 3 frames and then terminate, but it instead lasts for 4 frames. However, if I set the termination point at 0:07. it acts as it should, lasting for 2 frames and then terminating.

    After some more experimentation I noticed there's a spot where the animation catches up to itself at time frame 0:13. I had a theory that it might be due to the fact that the animation time frame (1/60) is a repeating decimal, I tried changing the animation time step to 1/40 and the sample rate to 40, and this issue still persisted (albeit on different points in the timeline). I even changed the time step to 1 and the sample to 1 and still got behavior like this.

    Does anyone know what's going on? My ultimate goal is to have complete control over how long an attack lasts in frames and at what points in said attack are the frames considered attacking and not. Again, this is a game where all the logic is frame based, not time based.
     
  2. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    This sounds like a good candidate for a bug report so Unity can give non-speculative feedback on the issue.
     
  3. MagicCancel

    MagicCancel

    Joined:
    Jul 30, 2015
    Posts:
    25
    So I just field a bug report, seeing that the bug exists in both the latest Unity 5 and Unity 2017. Thanks for the idea! Hopefully this can get resolved.
     
    theANMATOR2b likes this.