Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Suggestion] Movement (Tutorial Part 2 and 3) #6

Open
rhrlima opened this issue Jan 2, 2022 · 2 comments
Open

[Suggestion] Movement (Tutorial Part 2 and 3) #6

rhrlima opened this issue Jan 2, 2022 · 2 comments

Comments

@rhrlima
Copy link

rhrlima commented Jan 2, 2022

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.

@bend-n
Copy link

bend-n commented Jan 30, 2022

use a pr

@Salvakiya
Copy link

as per the godot docs... https://docs.godotengine.org/en/stable/classes/class_kinematicbody2d.html#class-kinematicbody2d-method-move-and-slide

"This method should be used in Node._physics_process (or in a method called by Node._physics_process), as it uses the physics step's delta value automatically in calculations. Otherwise, the simulation will run at an incorrect speed."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants