|Topic was automatically imported from the old Question2Answer platform.
If I use Navigation2D, my agents seek only for shortest way. But this way is not always good from tactical point of view. For i.e. short way can go through area occupied by soldiers with whom we don’t want to fight (or area can be locked by enemy sniper. Or there can be a mine field. Or shortest way to cover move agent to it without keeping covering obstacle between agent and player).
How to increase Navigation2D by ability to use that additional tactical information to find the optimal way? Can I do it by script or should I recompile the Godot?
no, Navigation2D cant do that for you. Imho i think the aStaral gorythm is suited way better for that task. But the implementation in godot is so simple that it cant provide a good solution for this either.
But the aStar algorythm is so simple and well documented that you can write your own in no time. Then you can implement your own field evaluation method into the calculation.
you can write your own in no time
Yes, I think so. Actually, I already have written at my own engine using c++, but I don’t know how to integrate it to Godot. Where can I see the Navigation2D or Astar2D sources to use it as example when create my own godot component? Can you point me to the right place at sources?
Robotex | 2020-07-17 16:01
this seems a good astar explanation
A* Search Algorithm - GeeksforGeeks
you can search the original source here
GitHub - godotengine/godot: Godot Engine – Multi-platform 2D and 3D game engine
and i remeber i once found a cpp addon for godot. But i havent remember/found it yet.
Google it yourself
i would advise your is
- dont make it grid based, make it node based. Its way more flexible that way.
- dont make it a “run once solution”, make it interuptable. Astar can be quit resource hungry. If you dont want your game to hang while calculating a long path you have to interupt the search process and continue it the next loop. (Godot doesnt do that and its nearly unuseable because of this)