Moving object not slowing down when the engines time_scale goes down, How do I fix this?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By sahish

I added a bomb that constantly goes up in a physics_process function. The player has the ability to slow down time, and when they do it changes the engines timescale to 0.05. When the player slows down time everything in the game except the bomb slows down.

Here is the code:

extends Area2D

func _physics_process(delta):
	if Engine.time_scale <= 0.05:
		global_position = global_position + Vector2(0,-0.25)
	else:
		if Engine.time_scale >= 0.05:
			global_position = global_position + Vector2(0,-1)
:bust_in_silhouette: Reply From: Kronos328

Hello! You have to multiply the value that you add to the global_position variable by the delta parameter on the function.

For example:

global_position += Vector2(0, -0.25) * delta

This “delta” is what ensures that the speed of the object will be consistent with the time_scale and won’t vary based on things like framerate.

Hope this helps!