Normalizing Animation Clip to One Second

Hi all, what I’m trying to do is set a variable for “AttackDuration”. This value would be the time, in seconds, it would take to complete the attack animation.

To do that, I figured I would have to normalize the clip lengths to 1 second, that way I would have a baseline.

To do that, I just used a simple:

timeDeltaPercentage = 1 / clipTime;

This gives me the difference in the clipTime to one second. i.e. a clip that was 1.5 seconds would give a percentage of .666667…

I then take that percentage and do the following calculation:

animatorSpeed = (1+timeDeltaPercentage) / targetAttackDuration;

This seems to get me almost all the way there but the numbers are off by around 10%.

Any ideas what I could be doing wrong?

Say your original animation duration is 0.5s
And you want it to be 2s
So you have:
Speed = 2/0.5

It’s that simple.