-
-
Notifications
You must be signed in to change notification settings - Fork 22k
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
Fix AStar2D, AStar3D, AStarGrid2D from not returning a path when the destination is disabled/solid even with allow_partial_path
option
#94246
Fix AStar2D, AStar3D, AStarGrid2D from not returning a path when the destination is disabled/solid even with allow_partial_path
option
#94246
Conversation
8cd3f8f
to
f13eabc
Compare
allow_partial_path
option
* AStar2D, AStar3D and AStarGrid2D will now return a path when allow_partial_path is true even if the destination is a solid/disabled point. # Conflicts: # core/math/a_star_grid_2d.cpp # core/math/a_star_grid_2d.h
f13eabc
to
c46b5af
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes sense, I guess
Thanks! |
@theashtronaut Thank you so much for your effort on this, it was driving me nuts having to disable all solids to calculate a path to them! |
Hi! I'm fairly new to Godot and Github, could someone explain to me what's going on here? Am I viewing a suggestion for a feature that may be implemented into the Godot engine itself, or an asset feature that can be downloaded and merged with a project by anyone? If it's the latter, how do I actually merge - do I have to download Godot source code and edit it, then relaunch my project in the modified Godot version or something else? I noticed that Godot 4.3 has "allow_partial_path" while 4,2 doesn't, but the 4.3 version still doesn't work like in the video, it returns an empty path when trying to click on a solid point. |
@Valar1415 This is an already merged feature. It should be in the most recent beta AFAIK. If you want to use it from source, all you have to do is download the current Godot master and build it, and launch the project in Godot built from source. Since it's already merged you do not have to create a fork and merge into it |
@Zireael07 so in my Godot 4.3 version this feature should work like in the video? Currently it doesn't and if it should, I should check that I haven't set up my function wrong. |
Godot 4.3 is from August, and this was merged in September. Try a beta version - afaict the most recent one is from October. |
Gotcha, that should be it. Tyvm for the help! |
Previously all of the AStar
_solve
methods would terminate early if the destination point was solid/disabled. This caused confusion amongst users who were expecting theallow_partial_path
option to still return a path even if the destination was solid/disabled. I fixed this by pulling that argument into_solve
and only terminating early if it was also false, so a path is still returned if the user uses the option.I noticed however while working on this that doing this significantly changes performance. I added a comment in the docs on the functions for these to warn users about this.
This will also happen whenever the end point is not reachable (aka the path is fully blocked off by solid/disabled points), however the code still executes even if
allow_partial_path
is false, as the pathfinding still has to run to determine if it is unreachable. I don't know if there is really a good way to fix this, as the only way to know a point is unreachable is traversing the entire graph anyway.I'm not sure if this should also be mentioned somewhere in the documentation though.
Sample output of a microbenchmark when the destination is a solid/disabled point or unreachable
Compared to when the point is reachable and not solid/disabled
This is with 1139 points in the graph.
Here is a sample project to test this:
astar_partial_test.zip
astar_partial_path_fix.webm
Closes #93409