- Home /
End slowmotion effect after x seconds
Hello! I am currently working on my first 2d game and everytime when the player dies i want a slowmotion to appear for a few seconds. I didnt figure out how i can have a function for a certain amount of time. Can someone help me with the script? The trigger of the slowmo will be an if method
public float slowdownfactor;
public float slowdownlength;
public gameobject player;
public void start()
{
if (player.activeSelf = false)
{
Time.timeScale = slowdownfactor;
}
}
...and so on. Now i just need help so set the slowdown length. I hope someone can help me:) ~dvxl
Answer by oboy_gamer · Mar 31, 2020 at 07:11 AM
Try using a Coroutie. Inside of the Coroutine you can use yield return new WaitForSecondsRealtime(slowdownlength);
to wait without being affected by the slow motion.
Your answer
![](https://koobas.hobune.stream/wayback/20220612230132im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Slow motion for Physics game 2 Answers
Is it possible to make a timer that ignores timescale? 2 Answers
Using Update loop vs Coroutine for exact timer 3 Answers
Powerup Timer not Working 3 Answers
Countdown Timer 1 Answer