Slowing down time?

How might I slow down time for every object in the level of a game, when I press a certain key? I need the effect to turn off after a specified time like 5 to 10 seconds…

I’m trying to test slowing down the speed of the animation on one object currently, but the script I’ve been given makes no sense to me… And I have yet to understand the instructions for using the script.

import bge
controller = bge.logic.getCurrentController()
owner = controller.owner

##User Variables#######

#name of the keyboard sensor (slow)
keyboard = ""
#name of the ipo property actuator
ipo = ""
endframe = 5
startframe = 1
speedfast = 1/15
speedslow = 1/30

###################

slow = controller.sensors[keyboard]
ipo = controller.actuators[ipo]

if not "count" in owner:
    owner["count"] = speedfast


owner["frame"] += owner["count"]   

if slow.positive:
    owner["count"] = speedslow
else:
    owner["count"] = speedfast
controller.activate(ipo)

Do you want help with the script? i wasn’t very clear.

Basically, you need to have three things:
A Sensor that you press to slow the animation
An Always sensor (true pulse) to keep the script running
An Actuator that you want to slow down.

Make sure that the animation isn’t run by another actuator.
make a note of the name of the sensor. Easy to use “slow”
make a note of the name of the actuator. Easy to use “anim”

Connect the sensor to a python controller, and type in the name of the script (in the text window)
Connect the always true pulse to the python controller
Connect the actuator to the python controller

In the script, look for the section (“User Variables”)
Change the value in the “” of the variable “keyboard” to the name of the sensor (my example was “slow”)
Change the value in the “” of the variable “ipo” to the name of the actuator (my example was “anim”)
Try it out!

If it plays too slow when you press the button, make the variable (speedslow) to a smaller fraction
If it plays too fast when you press the button, make the variable (speedslow) to a larger fraction

If it plays too slow when not pressing, make the variable (speedfast) to a smaller fraction
If it plays too fast when not pressing, make the variable (speedfast) to a large fraction

Im interested in thoughts about this matter as well, especially in terms of physics setting you can modify to give the illusion or fake the slowing down of time.

I still can’t make it work… Here’s a screenshot…

Attachments


I have slow motion in an old game I was working on if you still need the help.

Blender 2.49b: GameLogic.setLogicTicRate(2000)

Blender 2.5: bge.logic.setLogicTicRate(2000)

The higher the number, the slower the physics. However, be advised: the logic tic rate is also how many times per second all your scripts and logic bricks are evaluated, so it can cause a lot of slowdown unless your game is relatively simple.

Also, the scripts/logic bricks have to be aware of the logic tic rate, otherwise things like dLoc and dRot will cause very fast motion.