How to make slow time effect with duration

Godot Version

4.3

Question

Hi, in my game I have an item that can slow time, I use tween to slow down time but the effect is never finish
Any idea?

static func slow_time(t: Tween) -> void:
	t.tween_property(Engine, "time_scale", 0.5, 0.5)
	t.parallel().tween_property(Engine, "physics_ticks_per_second", 15, 0.5)
	t.tween_interval(_duration)
	t.tween_property(Engine, "time_scale", 1, 0.25)
	t.parallel().tween_property(Engine, "physics_ticks_per_second", 30, 0.25)

This piece of code works well for me.
What is your “_duration” variable value?
Remember that when you’re slowing the Engine.time_scale, your tween will also be slowed down. In your case, the _duration will take twice as long to finish + additional 1 second that your tweeners will be extended to.
E.g. I fed 2.0 seconds as the _duration and the tween lasted 5.0 seconds in total.

If you even set _duration to 0.1, it does not work. It seems like a static func causes a bug, but when I use func, it’s working.

func slow_time() -> void:
	var t = create_tween()
	t.tween_property(Engine, "time_scale", 0.5, 0.5)
	t.parallel().tween_property(Engine, "physics_ticks_per_second", 15, SlowTimeEffect.FADE_IN_DURATION)
	t.parallel().tween_callback(fade_in)
	t.parallel().tween_interval(duration)
	t.tween_callback(remove_slow_time)

func remove_slow_time() -> void:
	var t = create_tween()
	t.tween_property(Engine, "time_scale", 1, 0.25)
	t.parallel().tween_property(Engine, "physics_ticks_per_second", 30, SlowTimeEffect.FADE_OUT_DURATION)
	t.parallel().tween_callback(fade_out)

So did you fix your issue?
Mark your answer or mine as a solution to your problem, so that others can reference it, unless you have any further issues.