How can I make a time-slowing effect in the BGE?

In Jak and Daxter the Lost Frontier, there is a power known as Eco Reflexes that slows down time significantly, and lowers the pitch of sounds a bit. It colours the screen cobalt blue.

Now, how can I reproduce this same effect in the BGE? In my case, it would involve the scene lighting dimming a bit due to the fact that photons are travelling slower, and the scene lighting would go red rather than blue. The animations of objects would slow down, except for the player. How can I script this to happen in the BGE? Time slowing and speeding up effects are very cool for games.

Then simply make a script to lower lighting, increase players speed and animation speed.(so you actually speeding the player up while in slowmotion).

1 Like

There is a built in system in upbge to warp time

1 Like

I made my own script and made it so the lighting goes redder when time is slowing and bluer when time is speeding up, but the colour values always exceed their min/max values I have set them, and never return to normal smoothly. I also want the ingame mist to do this as well.

bge.logic.setTimeScale is a nice starting point for setting animations and physics speed. I once made a tutorial about slow motion in BGE here (in portuguese). As for the sounds and lighting, you would have to do it manually.

1 Like

i would just do something like below code and add a min/max into the equation if needed.

This is based of my slowmo script, it blends from basic white lamp(normal) → red light(slowmo is activated) → blue(slowmo is speeding back up) → white(time returned to normal)

it’s a shame that we simply can’t lerp colors

from bge import logic


def slow_motion(cont):

    own = cont.owner
    key = own.sensors['Keyboard']
    
    #minimum speed
    slow_min = 0.1
    #slow things down by ... a tic
    slow_step = 0.02
    #default = 1.0, lower means slower, higher means faster
    default_time_scale = 1.0
    
    time_scale = logic.getTimeScale()
    lamp = own.scene.objects['Hemi']
    
    r = lamp.color.r
    g = lamp.color.g
    b = lamp.color.b
    
    #do the magic
    if key.positive:
        
        if time_scale > slow_min <= default_time_scale:
            time_scale -= slow_step
            
            if r < 1.0 :
                r += slow_step
            if g <= 1.0 :
                g -= slow_step
            if b <= 1.0 :
                b -= slow_step
            
            lamp.color = [r,g,b]
        
    elif time_scale < default_time_scale:  
        time_scale += slow_step  
        
        if r <= 1.0 :
            r -= slow_step
        if g <= 1.0 :
            g -= slow_step
        if b < 1.0 :
            b += slow_step
            
        lamp.color = [r,g,b]
        
    else:
        if r < 1.0 :
            r += slow_step
        if g < 1.0 :
            g += slow_step
        if b < 1.0 :
            b += slow_step
            
        lamp.color = [r,g,b]
            
    logic.setTimeScale(time_scale)
    
    #play the (orange)animations (just a placeholder to do all by python
    armatures = [obj for obj in own.scene.objects if 'armature' in obj]
    
    for obj in armatures:
        obj.playAction('ArmatureAction.001', 0,19)

and then the same with the mist color

own.scene.world.mistColor = [0,1,0]