Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get smooth slow motion in Unity3D

Im trying to get a slow motion on the game im making but it looks realy laggy. Im using the FPS controller from the standard assets given by unity.I attached this script to it :

function Update () 
{
    if (Input.GetKeyDown ("q"))
    {
        Time.timeScale = 0.5;
    }

    if (Input.GetKeyDown ("e")) 
    {
        Time.timeScale = 2.0;
    }

    if (Input.GetKeyDown ("t")) 
    {
        Time.timeScale = 1.0;
    }
}

I know this is a similar question to this one http://answers.unity3d.com/questions/39279/how-to-get-smooth-slow-motion.html

but the fixes given on that question won't work.I tried adding a rigidbody to it and putting the Interpolation to Interpolate but it doesn't do anything.(I removed the tick from "Use Gravity" because the character started flying).Im new in unity and scripting so please go easy on me.

Thank you.

like image 487
Ssiro Avatar asked Sep 05 '25 01:09

Ssiro


1 Answers

You should change Time.fixedDeltaTime as well:

function Update () {
   if (Input.GetKeyDown ("q")){
      Time.timeScale = 0.5;
      Time.fixedDeltaTime = 0.02F * Time.timeScale;
   }
}

To return it to normal motion again you should call these two lines

      Time.timeScale = 1;
      Time.fixedDeltaTime = 0.02F * Time.timeScale;
like image 104
g8minhquan Avatar answered Sep 07 '25 17:09

g8minhquan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!