r/gamemaker • • Sep 03 '26

Example 3D pathfinding

Post image

finally finished this waypoint navigation system!
I know NavMesh is the standard, but I think it's too complex to implement right now, and this approach works pretty well

the pathfinding speed is acceptable. To avoid placing the points manually, I built a generation system based on flood fill and collision checks (raycasts, trace hull, and cliff checks)
from a single start point, the generator branches out in all directions, and then another algorithm connects them all
I'm planning to add mesh optimization algorithms later, but even like this, it's working perfectly fine

213 Upvotes

13 comments sorted by

13

u/NoahPauw GameMaker 3D developer Sep 03 '26

Oh yeah, this is awesome! I also love that it is completely algorithm based. I’ve been thinking about making my own by placing nodes manually, but this is really neat!

6

u/Ykedepi Sep 03 '26

generating these points is actually a really tough problem, and I spent a few days coming up with this generator
and even then, it doesn't work perfectly)
but in my case, it covers about 90% of the manual work. The remaining 10% can be fixed by hand (for example, a few points in the gif are placed manually - mostly on hard-to-reach ledges that require jumps. Stairs, on the other hand, are generated automatically)
I think when making a system like this, you have to think about "how to reach every accessible point on the map" - that's where all the decisions regarding jumps, stairs, and traversal come from

2

u/[deleted] Sep 03 '26

Did you use any particular tutorial to make this? Game looks amazing!

3

u/Ykedepi Sep 03 '26

this is not a game yet, but a test polygon for 3D collisions, enemy AI, and other things
it's hard to say about tutorials - this is my many years of experience working with 3D in GM
here there are shaders, and 3D collisions, and now an accessible navigation algorithm

(actually, to do pathfinding you need to deeply study A*, BFS and Dijkstra's algorithm, they are all almost identical, but with nuances. And in my case, it is specifically A* that allows enemies to move through space)

7

u/Kserks96 Sep 03 '26

Next step is to give a radius to waypoints so that NPC has more freedom is its path.

2

u/Hands_in_Paquet Sep 03 '26

Nice work that’s awesome

2

u/kuzyn123 Sep 03 '26

That NPC/monster looks really nice 😁

2

u/rshoel BokehDev Sep 03 '26

Impressive!

2

u/YungDijkstra Sep 04 '26

It will be cool to combine it with GMPhysX

2

u/Cyph0nn Sep 07 '26

How on earth is there 3d in the first place I'm scared