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

The Function moveToward need to be repaired #648

Closed
datouzhu125 opened this issue Jun 3, 2024 · 1 comment
Closed

The Function moveToward need to be repaired #648

datouzhu125 opened this issue Jun 3, 2024 · 1 comment

Comments

@datouzhu125
Copy link
Contributor

The moveToward function in GDMath class under godot.global package has wrong behavior when it goes from 0 to negative value.
I query realized the Godot source code,as follows.
static _ALWAYS_INLINE_ float move_toward(float p_from, float p_to, float p_delta) { return abs(p_to - p_from) <= p_delta ? p_to : p_from + SIGN(p_to - p_from) * p_delta; }
The implementation in Kotlin should be as follows.
fun moveToward(from: Float, to: Float, delta: Float) = if (abs(to - from) <= delta) to else from + (to - from).sign * delta
I don't quite understand how to submit a PullRequest

@CedNaru
Copy link
Member

CedNaru commented Jun 8, 2024

Fix by #649, thank for your input.

@CedNaru CedNaru closed this as completed Jun 8, 2024
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

2 participants