What does the '... * delta do?

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

E.G.

func _physics_process(delta):
position += position.direction_to(get_global_mouse_position()) * velocity * delta

What does the * delta do?

:bust_in_silhouette: Reply From: kidscancode

delta represents the amount of time elapsed during one frame. If your velocity is in units of distance/time (such as “100 pixels/second”), then multiplying by the frame time will result in the distance to be moved during one frame.

IE, if I have velocity of 120 pixels/sec and delta is 1/60 sec, then each frame I should move 2 pixels, and after a full second, I’ll have moved 120 pixels.

For a much more detailed explanation, with examples and animations, see here:
http://kidscancode.org/godot_recipes/basics/understanding_delta/

correct me if I’m wrong, delta adds up to 1 in one second right? because that would explain why (* delta) works even though delta is not constant

CakeLover | 2022-01-04 19:02