Search Unity

Question How to adjust animation to movement speed?

Discussion in 'Animation' started by Zimaell, May 27, 2023.

  1. Zimaell

    Zimaell

    Joined:
    May 7, 2020
    Posts:
    409
    I had a problem with moving, on the one hand it moves well with the help of the root movement, but the network is out of sync, on the other hand, just moving the object everything works synchronously, but it moves unrealistically.
    in the end, I came to the conclusion that you need to (somehow) adjust the speed of the animation (animator.speed = ...) to make it look more realistic. but how to do that?
    does anyone have any tips on this?
     
  2. Zimaell

    Zimaell

    Joined:
    May 7, 2020
    Posts:
    409
    I tried to tweak the speed manually, in principle, you can achieve a realistic result, for example, I took 2 walking / running animations (31 and 21 frames) from mixamo, then set the animator speed (S) to 0.55 for walking, and running (S) to 0.2, then I already change (S) and looks more or less.
    (S) the speed of the movement of the object, and 0.55 and 0.2 the speed of the animator.

    The question is - does each animation really need to select a value manually, or can it be calculated using some kind of formula?

    (I still can't find patterns...)
     
  3. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,442
    Walking and running animations are usually designed for root motion, or at least with a linear speed in mind. You can usually find that linear speed if you just animate it and let root motion do the work, measuring the distance covered vs the length of the loop. If the animation is an "in place" animation without root motion (which is getting pretty rare these days), you have to experiment to find the speed that has the least "skating" or slip of the foot relative to the ground.

    When you decide to make things move based on something other than time (such as server movement updates), you should not let the animator drive things with root motion anymore, or they'll get out of sync with what the server is trying to dictate. It can get complicated but the concept is fairly straightforward. You will have to basically compute the animation time position based on where the server says the object now belongs. If the running clip naturally traverses 2.5 meters per loop over 1 second, but your server update moved you 0.5 meters, you can do the math to decide to advance the animation by 0.5/2.5 or 0.2. It's not likely you will have a server update ready on every frame, so you may need to keep track of the average frame speed and update the animation at that rate.
     
    Zimaell likes this.
  4. Zimaell

    Zimaell

    Joined:
    May 7, 2020
    Posts:
    409
    I did a test - I started the root animation with a speed of 1, one cycle of walking is equal to 3.64-3.66 meters, I don’t even know how to apply this data.
    means for each animation manually select, at least I see the effect in this ...