- Home /
Slow motion problem
I made some scripts to slow down the time whenever an object hits a collision box that activates the slow motion. The slowdown time is 1 second but the slow motion never stops. I also tried to write a new script that deactivates the slow motion when the object is hitting anything else than the slow motion collision box I made and it stops the slow motion but my objects start to move 2 times faster than normal or so. Can anyone tell me what is wrong in here because it seems like I can't figure it out. I will let the scripts below, the first is for slowing down time and the second is for making it "normal" (but not normal because it doesn't work...)
 using UnityEngine;
 
 public class TimeManager : MonoBehaviour
 {
     public float slowdownFactor = 0.2f;
     public float slowdownLength = 1f;
 
     void FixedUpdate()
     {
         Time.timeScale += (1f / slowdownLength) * Time.unscaledDeltaTime;
         Time.timeScale = Mathf.Clamp(Time.timeScale, 0f, 1f);
         if (Time.timeScale == 1.0f)
         {
             Time.fixedDeltaTime = Time.deltaTime;
         }
     }
     public void DoSlowmotion ()
     {
         Time.timeScale = slowdownFactor;
         Time.fixedDeltaTime = Time.timeScale * .02f;
     }
 }
Slow motion script above ^ and stop slow motion script below.
 using UnityEngine;
 
 public class TimeManager2 : MonoBehaviour
 {
     public void StopSlowmotion()
     {
         Time.timeScale = 1f;
         Time.fixedDeltaTime = .02f;
     }
 }
Answer by pandagamingroyt · Jul 30, 2020 at 05:25 PM
I managed to fix this with this amazing answer http://answers.unity.com/answers/39282/view.html (All I needed was Time.timeScale and to enable interpolation on all my moving objects)
Your answer
 
 
             Follow this Question
Related Questions
how to get smooth slow motion? 4 Answers
Altering Fixed Timestep when your game is running to allow for smooth low Timescale animation. 2 Answers
My objects are falling to slowly when a rigidbody is attached, cab you help? 9 Answers
Transform.Rotate not affected by Time.timeScale 1 Answer
Slow motion all but one - yet another round, hopefully the last 6 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                