Thanks
Thanks to paddy-exe and their GDExtension Template (https://github.com/paddy-exe/GDExtensionSummator)
GodotFlowfield
A Flowfield Pathfinding implementation for Godot. It is very barebones and was only used in my currently on-hold tower-defense game.
Some limitations:
- No variable costs
- No negative costs
- Only works in positive coordinates (0,0 -> towards positive) due to naive array access for speedup
- Quite optimized
Video
Here is a video of it "in action". First video was a sort of "speed test". I randomly generate a tower every x ms (don't remember right now, will look up) and place it randomly on the map. Then the flowfield checks if the tile the tower is supposed to be placed on is free.
Free here means:
- Not blocking the remaining path for enemies
- There is nothing else already built there
Second video is showing the updating of the flowfield in more detail:
And here is a screenshot with "distance to target" shown:
I'll try to provide a simple documentation sometime.
Stats
From some experiments back then (I'll have to redo testing, but this is what I wrote down):
Calculating a flowfield for an empty 30 by 40 cell map:
GDScript ~6ms
C++ (after optimization): 0.8-1ms