X Tutup
Skip to content

Fix description about CharacterBody velocity and delta#111102

Merged
Repiteo merged 1 commit intogodotengine:masterfrom
timothyqiu:velocity-delta
Oct 7, 2025
Merged

Fix description about CharacterBody velocity and delta#111102
Repiteo merged 1 commit intogodotengine:masterfrom
timothyqiu:velocity-delta

Conversation

@timothyqiu
Copy link
Member

This property should not be set to a value multiplied by delta

The way values are calculated should not be discouraged. It's the unit that matters. For example, multiplying an acceleration by delta gives a perfectly normal velocity vector.

@timothyqiu timothyqiu requested a review from a team as a code owner October 1, 2025 02:02
@aaronfranke
Copy link
Member

This text was recently added by @RolandMarchand in PR #109925, maybe he would like to give feedback on this.

@RolandMarchand
Copy link
Contributor

The way values are calculated should not be discouraged.

Errors should be discouraged, and multiplying a velocity vector by delta twice is a significant physics calculation error. This happens when the user multiplies velocity by delta and then uses move_and_slide() which internally also multiplies the velocity by delta. Users should never do that, so it should be discouraged. We can argue about the specific language used, but I have not heard a single complaint about it.

@timothyqiu
Copy link
Member Author

timothyqiu commented Oct 2, 2025

@RolandMarchand This PR is saying the same thing as you're describing.

The original sentence discourages any form of x * delta. This PR changes it to noting that px/s * delta is a common mistake.

The key point is, x * delta is valid as long as x is in px/s².

The root cause of the error lies in users not caring about the units of values. The original wording not only has false positives, but also encouraged the root error rather than resolving it.

Copy link
Member

@aaronfranke aaronfranke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of these days it would be cool to add F#-style units to GDScript.

Copy link
Member

@Mickeon Mickeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do personally prefer the wording in this PR, albeit it's a bit too technical. Note that there's a similar remark in move_and_slide's description that should probably be changed for consistency.

@timothyqiu
Copy link
Member Author

Note that there's a similar remark in move_and_slide's description that should probably be changed for consistency.

@Mickeon I think that part is fine since it's just explaining why move_and_slide() should be called inside _physics_process: the method depends on the current physics delta internally.

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

@Repiteo Repiteo merged commit ec7d25d into godotengine:master Oct 7, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Oct 7, 2025

Thanks!

@MadeScientist
Copy link
Contributor

MadeScientist commented Oct 7, 2025

I think the focus of his problem is not on the unit, but on clearly stating in the description of the move_and_slide method that the delta parameter has already been used for calculation. Similar to what the direction_to method explicitly states as returning a normalized vector. At present, this page(https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#move -and-slide) indicates this point, but the built-in document method description has not been updated synchronously.
This 'delta-related' thing only clearly stated in the description of the move_ond_comlide method like "Moves the body along the vector motion. In order to be frame rate independent in Node._physics_process() or Node._process(), motion should be computed using delta".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

X Tutup