godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.8k stars 20.92k forks source link

CharacterBody2D template uses `move_toward` incorrectly #74216

Open ghost opened 1 year ago

ghost commented 1 year ago

Godot version

4.0 stable

System information

win 11

Issue description

If you select the CharacterBody2D template, you get this line:

velocity.x = move_toward(velocity.x, 0, SPEED)

However, the docs say that the third parameter is delta. This means that velocity.x is set to 0 immediately since it can't be any greater than SPEED. The line could be replaced by velocity.x = 0.

I think the line should be replaced by velocity.x = move_toward(velocity.x, 0, SPEED * delta), right?

Also, someone on Discord confused the delta of the move_toward function with the _physics_process delta. Perhaps the docs should clarify that they're not the same and that delta just means change?

Steps to reproduce

Make a CharacterBody2D with the default template for it.

Minimal reproduction project

N/A

akien-mga commented 1 year ago

Should be fixed by #73873.