SlowMotion Effect inside Animation - Almost Solved

Hi all!
Here is a half-working script for “slowmotion” inside an animation.
So I’m writing for 2 reason, As I was Google:ing this function I never found what I was looking for so I think this could be helpful to other beginners, so in case someone is looking for this function in the future, this might work… and - I’m also asking for help to make it work even better.

How it works:
Im using this effect when My player make a PowerJump move. He jumps up in the air, flip and stomp down.
It looks cool but it looks even better if its a slight slowmotion effect when he does the Air Flip. This script slow down the whole game while he is doing the back flip. All you have to do is add these flags to the Animation Timeline, select the slowMotionEffectStart and slowMotionEffectExit and its all good…

Attach these simple lines inside any script that is attached to your player:

void slowMotionEffectStart()
    {
        Time.timeScale = 0.5f;
        Time.fixedDeltaTime = 0.02f * Time.timeScale; //SlowmotionEffect
    }
void slowMotionEffectExit()
    {
        Time.timeScale = 1f;
        Time.fixedDeltaTime = 0.02f * Time.timeScale; //SlowmotionEffect
    }

Is there a better way to add a slowmotion effect inside an Animation?
Is it possible to ONLY slow down the player, not the entire game?
Other then that, this function is great for Picky creators who want to slow down time in certain areas inside the animation :slight_smile:

cheers!

Yes Problem adding individual clip speed - Questions & Answers - Unity Discussions

1 Like

Look like that will change the speed of the whole animation, not induvidal parts of the animation?

How are you doing your animations? There is all kinds of ways to control the speeds with the state machine.

Im making them in Spriter and exporting a bunch of pictures into Unity. :slight_smile:
I have no idea how Unitys built in system works :S I guess i could draaaag out parts of the animations to give it a slowmotion effect. but Im scared that the files will be to many evetually :S Thats why I want to cotnroll the animations thogh script :S