-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Add move_toward() methods for Vector4, Float. #5596
Comments
It sounds like your use case is solved using the slerp method of the basis/quaternion types, which are the types that represent 3D rotations in Godot? spherical linear interpolation is required to get correct interpolation of rotations. While move toward implies plain linear interpolation, which would result in wrong results. In fact... are you familiar with lerp() in general? |
I did end up using lerp_angle for what i was doing, though as described in the proposal i linked it moves it by the ratio rather than the increment. |
Regarding incrementing (Relevant: #330 ; Only static func get_angle_difference(from: float, to: float) -> float:
var diff := fmod(to - from, TAU)
return fmod(2.0 * diff, TAU) - diff
static func move_toward_angle(from: float, to: float, delta: float) -> float:
var diff := get_angle_difference(from, to)
return from + minf(absf(diff), delta) * signf(diff) However, I wish I didn't have to write these in every project. I'd give my vote to bringing these two to the core. |
Describe the project you are working on
A simple 3D platformer test.
Describe the problem or limitation you are having in your project
Wanted to make the character smoothly rotate towards the direction they're facing, at a constant speed, ran into a problem where i cannot use move_toward() because of euler rotation issues (the character spins around the other way upon reaching 360 degrees). I have then looked at solutions in the documentation to find there isn't an equivalent of move_toward() for rotations (#2074), and that move_toward() method doesn't exist in a few other classes.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
A move_toward() method for Vector4, working the same as in Vector2 and Vector4.
A move_toward() method for Float, that's different from the one present in GlobalScope by being written more similar to the one in Vector2/3, as they have different colored highlights (former is lavender and the latter is blue), and just in case anyone prefers to write it that way.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Vector4
Float
If this enhancement will not be used often, can it be worked around with a few lines of script?
Possibly, although it might be easy for a beginner to code, as well as having to put it in every file using it.
Is there a reason why this should be core and not an add-on in the asset library?
Improving the consistency of the editor out of the box.
The text was updated successfully, but these errors were encountered: