-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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_angle and angle_difference methods #69081
Conversation
b10d941
to
08b79f4
Compare
Since 4.0 is in feature freeze and since .NET 6 isn't mentioned in the compiling docs i assume building the C# version isn't fully documented yet, i'll most likely just wait for 4.0 to go in stable before updating the PR again. |
@ettiSurreal Oh, this is great to see! Though to stay in line with other functions, should Also one other consideration is that in the Here's the plugin I made that implements it in case you're curious! |
To make things easy to track, make sure to squash your commits into a single commit. 👍 |
Bump. What's the state of this? Can this go into 4.0 or is this something that's for 4.1? |
Any non-critical change is for 4.1 at the earliest now. |
I couldn't squash the commits on this branch since Git Bash stopped working for me, and Github Desktop just keeps throwing an "Unable to squash" error. |
Hopefully this can get added by 4.2. |
You will have to squash before this can be merged once approved, hopefully you can get it to work, a maintainer can attempt to do so however |
I feel like i may have just mishandled doing it, so if approved I'll probably just redo the PR/Branch. |
I'd suggest either trying to fix it or do that before any approval, rather than waiting as reviewing would also depend on it being up to date and possible to test properly against the current codebase |
This comment was marked as outdated.
This comment was marked as outdated.
I wanted to try doing something myself one more time but I guess you beat me to it due to my atm painfully slow internet, other than that i only used Github's Sync Fork because it seemed to do the job, and I'm still very new to this. |
It's hard, so no worries, I've struggled at the start too! |
I'll try to rebase. 🙃 Edit: Rebased. I think I haven't changed anything besides the commit name. Generally the PR looks ok, I'd say the docs need some more clarification. But I'm not fully sure what's the desired behavior in the first place. E.g. for the current implementation: move_toward_angle(deg_to_rad(3600), deg_to_rad(90), deg_to_rad(45)) # Returns: deg_to_rad(3645)
move_toward_angle(deg_to_rad(90), deg_to_rad(3600), deg_to_rad(45)) # Returns: deg_to_rad(45)
move_toward_angle(deg_to_rad(0), deg_to_rad(90), deg_to_rad(3600)) # Returns: deg_to_rad(90)
move_toward_angle(deg_to_rad(0), deg_to_rad(90), deg_to_rad(-3600)) # Returns: deg_to_rad(-3600) Is this expected/desired? Or do we maybe want to somehow limit the results to some range (like |
998feb6
to
08e5b75
Compare
Thanks for the help!
As for the docs i am not the best at writing those, I think someone might rewrite this sometime. |
In case it helps, I wrote my function docs (and names) to mirror Godot's, so feel free to pinch them if you'd like! Also regarding @kleonc's comment, in my GDScript implementation the result of |
@adamscoble I just straight-up copied the
|
Oh, well there you go! I don't use the lerp functions often for this stuff — I created a float smoothing class in that same repository to avoid the framerate-dependent smoothing of lerp. So it seems you're being consistent with Godot! |
@adamscoble Your implementation behaves the same as the one in this PR, note the examples I gave in #69081 (comment) are kinda edge cases (like why would you want to move away by 3600 degrees?). For both implementations if For the As a simple example, what should be the result of: move_toward_angle(deg_to_rad(90), deg_to_rad(0), deg_to_rad(-180)) Which can be interpreted as: we're at 90 degrees and we're moving 180 degrees away from 0 degrees. But maybe the current behavior is desired, I don't know. What I'm saying is that firstly the expected behavior should be well defined for all possible inputs. Tweaking the implementation/docs accordingly is the next step. |
I'd say it should work the same as |
Tested some things out in a GDScript port of the functions.
would return -90 degrees, since negative values currently do not support stopping at at the opposite angle. Which would mean if you run it per frame it will oscillate. Also I'm sorry, I'm still unable to squash the commits, I get an error when i attempt to use $ git rebase -i upstream/master and $ git fetch upstream master. |
Closes godotengine/godot-proposals#2074
Adds:
angle_difference
, which finds a value between 0 and TAU, finding the shortest path.move_toward_angle
, moves towards an angle by an increment, wrapping around TAU and also finding the shortest path, similar tolerp_angle
.lerp_angle
code to avoid repetition.Implementation based on godotengine/godot-proposals#5596 (comment) and #37078.
Tested on a custom build, everything seems to be working as it should.
This is my first time making a PR, so let me know what to do if i messed something up!!