0 votes

E.G.

func physicsprocess(delta):
position += position.directionto(getglobalmouseposition()) * velocity * delta

What does the * delta do?

in Engine by (99 points)

1 Answer

+1 vote
Best answer

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/

by (21,714 points)
selected by

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.