How to set part of animation to play at different speed?


I have this problem. I have a character that runs by itself (not by user input) and has animation for that, then he must jump forward (also automatic) and then he falls down (no user input here either). Everything works just fine, but the ‘obstacle’ varies in sizes so sometimes i need to stay longer in the air to complete the jump. I tried manipulating animation speed, but it turned out that slowing down running and falling down does not look good. All this animation is called only once (so i have difficulties implementing three animations for each action).

My question: Is it possible to change animation speed of part of this animation? For example i can split animation to clips by code, change speed for one of those clips, join 'em all up and run that then?

Maybe someone have run into similar problems. Thanks in advance.

It its all one animation you can wrtie some code to slow down part of it like this

if((animation["animatioName"].normalizedTime > 0.25f)&&(animation["animatioName"].normalizedTime < 0.75f))
    animation["animatioName"].speed = 0.5f;

That would slow down the middle 50% of the animation by half.

Or you can split the animation when you import it and play the animations sequentially. And slow down the section you want.

You could put box colliders around the obstacles and set them to triggers, then detect when the character is inside. Once he is, you could slow down his controller movement or whatever method he uses to actually move forward. Then of course after he exits the trigger you could set his movement speed back to normal. Of course this would only work if you are translating him across the map, and not just using animations that move him forward. Just an idea.