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?
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?
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)
And here's an example .blend. Note that you'll need a recent version of blender for it to work.