godotengine / godot-docs

Godot Engine official documentation
https://docs.godotengine.org
Other
3.94k stars 3.22k forks source link

AStar3D example code for _compute_cost() and _estimate_cost() nonsensical #10230

Open Nebulous5 opened 4 days ago

Nebulous5 commented 4 days ago

Your Godot version: 4.3 and Latest

Issue description: The example code in the doc for AStar3D for _compute_cost(u,v) and _estimate_cost(u,v) makes no sense in both GDScript and C#. Unless I'm mistaken, u and v are point ids not point vectors, so these examples compute a value based on subtracting ids which is meaningless.

It should be something more like get_point_position(u).distance_to(get_point_position(v)) for points in euclidean space.

If the intent was really to compute/estimate a cost based on point ids, can someone explain in what situation these examples make any sense?

URL to the documentation page: https://docs.godotengine.org/en/latest/classes/class_astar3d.html https://docs.godotengine.org/en/stable/classes/class_astar3d.html

tetrapod00 commented 4 days ago

Indeed, these examples don't make much sense. I suppose they could make sense if the "distance" you're measuring is the order that IDs were added?

Something like manhattan distance might be a better example to use.