Slow motion

Topics: Developer Forum
Mar 31, 2012 at 9:27 AM

Hi, I have small problem, that I can't solve by myself. I try to add slow motion in my game and use world.Step (dt), where dt - float from 10.0f to 0.000000000001f and nothing happens with my ball. It still moving fast, what I do wrong?

Apr 1, 2012 at 1:13 AM

Instead of trying to change the time in the world step, why don't you slow down how often you are calling World.Step(). Don't change the number of drawing calls just the update calls. Here is an example in XNA. All you have to do to slow down time is to keep track of how often you want to update the world. You can play around with the numbers but this is how you could achieve slow motion.

double timeToUpdate;
public void Update(GameTime gameTime)
            timeToUpdate += gameTime.ElapsedGameTime.TotalSeconds;
            if (timeToUpdate >= .05d)
                timeToUpdate = 0d;
                world.Step((float)gameTime.ElapsedGameTime.Milliseconds * 0.001f);