An easy way to do this is to change the
Engine.time_scale temporarily using timers. You would also want to be careful to cancel out the scaling to the time used in some way, so it isn't also slowed down.
That can be done by multiplying the scale into the duration used, or dividing the scaling out of the delta if you're using processing.
A basic example looks like this. This will slow time to 30% for 1 second for pressing any button. The timer refreshes for multiple presses.
You can also get fancier results by using easing on the value used for scaling to have it ramp up or down over time.
const SCALE = 0.3
const DURATION = 1.0
var time_remaining = 0.0
func time_slow(duration, amount):
Engine.time_scale = amount
time_remaining = duration
if(time_remaining > 0.0):
time_remaining -= delta / Engine.time_scale
if(time_remaining <= 0.0):
Engine.time_scale = 1.0