Implement recast navigation

I’m looking for someone who would like to implement the recast navigation from GitHub into PlayCanvas.

With this I want to create a template that other users can use in their project. I think it would be great if pathfinding was finally possible in PlayCanvas.

Unfortunately, I don’t have the necessary basic knowledge to start with this, so perhaps a first start or a similar project with another GitHub intergration (to use as an example) can help as well.

Thanks!

1 Like

This would be awesome!

Hi! I’d be happy to help with this :smile:

What’s the current playcanvas story for using dependencies from npm? I recall seeing a tweet teasing support for npm packages but I don’t know if that’s released?

I also added an example to the repo for using the library without a bundler via a CDN, which could help here: recast-navigation-js/examples/no-bundler/index.html at main · isaac-mason/recast-navigation-js · GitHub

That example uses three.js for rendering, and uses some utilities in @recast-navigation/three for getting positions and indices from three.js meshes, but the core library isn’t tied to three.js at all. A playcanvas implementation of the debug drawer could easily be created as well.

1 Like

NPM support coming sometime later this year. For the moment, they need to generate a UMD version with the dependencies to use within the editor

1 Like

Hi @isaacmason and welcome!

Thanks a lot for your reply! :star_struck:

As @yaustar already mentioned, this is not available yet unfortunately.

It’s probably not that difficult, but even though I can do some coding, I’m not a developer.

That’s why I was hoping for some help. :see_no_evil:

2 Likes

Thanks for the info @yaustar! And no worries @Albertos.

Right now recast-navigation-js only has an ESM build.

If ESM isn’t supported and it’s not on the roadmap, I can consider adding a UMD build.

Though it looks like using ESM dependencies is at least possible with importmap?

That post was for engine only. ESM modules support is on the road map and is currently being worked on for a release or beta test over the next few months

For now, I would use a UMD build or browserify it

1 Like

Thanks for the clarification :slight_smile: noted

For now I’ll wait until ESM is supported to create a playcanvas demo, unless anyone specifically wants help with this before then.

2 Likes

This is a very quick editor project that demonstrates the multi agent path finding with Recast/Detour using ESM Scripts

Recast + Detour NavMesh Demo.

I’ll submit a PR against @isaacmason’s library so that you can just import a playcanvas specific package via @recast-navigation/playcanvas. You can see this here GitHub - marklundin/recast-navigation-js: JavaScript navigation mesh construction, path-finding, and spatial reasoning toolkit. WebAssembly port of Recast Navigation.

2 Likes

This is amazing! Thank you very much! :heart_eyes:

1 Like

Actual pathfinding in playcanvas will finally allow me to make a ton of ideas I’ve had.

1 Like

I tried to use the example of @Mark_Lundin to create my own version. I’m not sure yet how to create the agents with entities from the editor. Additionally, I noticed an issue where the agent’s position changed unexpectedly. You can see this in the video below.

Do you have any idea what the problem could be @isaacmason?

https://playcanvas.com/editor/scene/2098402