11
$\begingroup$

I'd like to transition from normal speed to slow-motion on certain events, such as a keypress.

Is it possible to animate time in the game engine?
If so, how?

$\endgroup$
11
$\begingroup$

This functionality has just been added. It will be in 2.77, until then it's only available in development builds.

  • getTimeScale(): Get the time multiplier between real-time and simulation time. The default value is 1.0. A value greater than 1.0 means that the simulation is going faster than real-time, a value lower than 1.0 means that the simulation is going slower than real-time.

  • setTimeScale(time_scale): Set the time multiplier between real-time and simulation time. A value greater than 1.0 means that the simulation is going faster than real-time, a value lower than 1.0 means that the simulation is going slower than real-time. Note that a too large value may lead to some physics instabilities.

You can set the time scale with bge.logic.setTimeScale(multiplier), where multiplier is the number by which the base timestep is scaled.

For example, here's a simple function to toggle between slow-motion and normal-motion:

from bge import logic

def toggle_slomo():

    if logic.getTimeScale() < 1:
        logic.setTimeScale(1)
    else:
        logic.setTimeScale(.1)

enter image description here

And here's an example .blend. Note that you'll need a recent version of blender for it to work.

$\endgroup$
  • $\begingroup$ it's Jack Sparme from blenderartists.org ^_^ this is very useful, many thanks. $\endgroup$ – user20965 Jan 16 '16 at 7:47
  • $\begingroup$ @JackSparme Glad to hear that :) $\endgroup$ – gandalf3 Jan 16 '16 at 8:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.