How to add 3D Navigaton/Pathfinding?

Hi everyone,

I want to implement 3D pathfinding for my NPCs to the project I am working on and I am curious about the different approaches one can take to achieve this.

I know there is the “Defold Detour” asset but I would like to learn about any alternatives one could use (or you are using)

My world was actually tile-based, and I was using 2D pathfinding for this: https://x.com/selimanac/status/1886859611938213941

But the best (and perhaps only) option for 3D space is a navmesh(Defold Detour), especially if you want to include different heights like platforms or ladders.

If the world is flat you can simply use ray casts for vision cone and direct the enemy to the player by preventing obstacles.

4 Likes

Thank you. I will keep this in mind

If you can make Detour to work and have tutorial on it would be so cool :grin:

3 Likes

I was hoping someone else has already suffered for a tutorial so I will not have to :sweat_smile:

Since I could not find one, I will see what I can do about it

1 Like

However, the choice of algorithm can vary depending on the project. In a flat environment, a straightforward A-star algorithm may suffice. For instance, I employed this approach: https://www.youtube.com/watch?v=Q9rUgZJ1HXQ&feature=youtu.e. The map was dynamically created at the beginning of the level, with multiple rays per cell perpendicular to the level. If these rays encountered a collider, the cell was designated as untraversable.

1 Like

That’s a good approach. And I love your 3D examples on the channel. I will keep in mind using the ray-cast approach for flat terrains.

For now, I will work on Detour asset as I want to make an extensive 3D tutorial :slight_smile:

1 Like

It should work for even non-flat terrains :slight_smile: Thats how I am using it also. Raycast a grid of rays like rain falling down and continuously 16 raycasts per frame. Which probe the surface and create a heightmap. Then you can use it for A-star as a cost function. Only issue it can be expensive and obviously you need a lot of those rays to cover large map, and can easily miss small obstacles

1 Like