Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Animation don't line up frame by frame without using transition offset

Discussion in 'Animation' started by volkerror, Apr 8, 2020.

  1. volkerror

    volkerror

    Joined:
    Apr 5, 2018
    Posts:
    16
    Hi there,

    thanks to Unity and all the great tutorials out there I've got a little 3D-RPG up and running within one month which is kind of a dream come true for me. I had to learn to program C# (I just knew C++ basics from years and years ago) model, rig and animate with Blender along the way ... slowing my progress. But every problem was solvable with the help of google, youtube and you good people of this forum. =) Now I've hit a brick wall and for the life of me can't find somebody who had the exact same problem in the past. So I'm guessing it's something very simple. But I'm stuck anyway.

    I am trying to sync animations of two characters (attack and hit). And they do so (frame by frame) in blender. In Unity I had no such luck. First I fiddled around with AnimationEvents and whatnot, but in the end they were to unreliable for me (e.g. not firing at the end of an animation because of transitions). Or at least *I* couldn't get them to work properly.

    Now I use code and start both animations right after one another (and a Debug.Log confirms, that the starting times are exactly congruent). For debug purposes I even had both start on keypress. But they wont sync as well as they should. The animations have the exact same frame count (in Blender as well as set in the Import Settings). I've changed "Exit Time" to 1 enabled/disabled "Fixed Duration" and altered the "Transition Duration" (0 to 0.5). Nothing made the slightest difference. There always is an offset of a few milliseconds, ruining the whole thing because of weird mismatch.

    I seem to be able to reduce the delay by using a "Transition Offset" of roundabout 0.03. But

    a) this seems to be a quite hacky way to do it,
    b) this is an extra step I have to think of for every animation with two characters
    c) I'm not sure if there will be a buildup if I string more animations together and
    d) the problem could be a symptom of me not understanding basic animation principles, f-ing up my little project in the long run. =)

    So if anyone could put me on the right tracks to where my glitch could result from, I would be much obliged.

    Cheers,
    Volkerror

    P.S.: And please do excuse my English.
     
  2. volkerror

    volkerror

    Joined:
    Apr 5, 2018
    Posts:
    16
    I couldn't solve the problem (animations wouldn't line up, even if the length was exactly the same) and I also couldn't find the reason for this strange behaviour.

    But if anyone else encounters this problem, my workaround was to add a StateMachine with an added script which starts the second, corresponding animation (on the NPC) OnStateEnter. Not elegant, but works like a charm. =)

    And using rootmotions FinalIK asset helped tons to get rid of the last bit of slipping and sliding.

    Cheers,
    Volkerror