-
Notifications
You must be signed in to change notification settings - Fork 293
Description
Hi, thanks for this amazing tutorial series on Action RPG games, I started watching them to learn Godot, and recently watched Part 2 and 3, related to player movement.
Regarding movement, you mentioned some improvements that viewers broght to you, and I want want to add something:
You don't have to multiply delta as you calculate acceleration and friction to update your velocity, since it's used in both cases, it just makes more sense to multiply the final velocity.
if input_vector != Vector2.ZERO:
velocity = velocity.move_toward(input_vector * MAX_SPEED, ACCELERATION)
else:
velocity = velocity.move_toward(Vector2.ZERO, FRICTION)
move_and_collide(velocity * delta)
As you mention in the video, delta is a value that helps us control how the player moves across different setups (with some computers being faster than others), its value is not directly related to the speed calculation itself, so we don't have to worry about while calculating the velocity.
With this change, we can still use the values for MAX_SPEED, ACCELERATION, and FRICTION as before (100, 25, 25), which again, makes more sense.