ramaureirac / godot-tactical-rpg

A tactical role-playing game demo for the Godot Engine
MIT License
625 stars 73 forks source link

[SUGGESTION]: Offload the pathfinding logic to NavigationServer #6

Open dukemagus opened 1 year ago

dukemagus commented 1 year ago

While a relatively recent feature, it should be theoretically possible to define a 3d grid as a navmesh, let it pull any move cost or obstacle modifier from the object in that space and then return the route.

It isn't as performant as a hand crafted A* implementation, but it's also a core component of the engine rather than running interpeted gdscript files. It should scale better if for any reason someone wants to do a map with many units or complex movement rules.

https://docs.godotengine.org/en/stable/classes/class_navigationserver.html

ramaureirac commented 1 year ago

I remember that I started this project using navmesh + grids but soon after I ran into problems related to the movement radius of each character, also if (I'm not mistaken) at that time it was not possible to generate a navmesh between two different objects and made more difficult the idea that I had for creating maps.

I guess looking for navigation server should be a good starting point if you start from zero (specially now with godot 4), however change such core logic its too time consuming and complex for me right know. However i'm still open to accept any pull request related to pathfinding :)

dukemagus commented 1 year ago

https://youtu.be/QRr_P_uqz8w

Was the class (AStarGrid2D) available when the project started? It seems to be able to make things easier. It only needs some parameters for height and movement coat to be dialed in, but it needs less code than the previous astar class and nodes

ramaureirac commented 1 year ago

according to the documentation it is a new feature for 2d nodes. for 3d a better choice should be AStar3D https://docs.godotengine.org/en/latest/classes/class_astar3d.html which is also included in Godot 4.

however, you still have to attach each point and check all routing conditionals manually. so, in a way, you will end up saving around 20-30 lines of pathfinding code, but creating new ones just for creating a communication between meshes, vector3s and characters.

for now I think it's better to wait until it supports custom nodes as input