Hi Needle Team,

I would like to create games which use IA. When I’m watching how to do it on unity, they use NavMesh a lot.
Do Needle implement it ? I didn’t find it on the documentation.

Have a good day

Original Post on Discord

by user 224464722878005248

Hi, we dont have a NavMesh implementation right now but it should be relatively easy to get something going with GitHub - donmccurdy/three-pathfinding: Navigation mesh utilities for three.js, based on PatrolJS.

Oh thank you very much !

by user 224464722878005248

Hi, it’s me, again

I’m currently working on adding NavMesh custom component by using needle to simplify Navigation for other project.
But I have a difficulty about the file extension NavMesh from unity.

Basically, the library PathFinding use the NavMesh as a glb file and it’s load separatly than the model (the level model)

Problem : in Unity it’s a NavMesh.asset which is used as information file in the scene
Not as a 3D Mesh.

Do you have an idea of how automatically export it as glb ? (I tried to find how do it manually on unity it seems that it can’t)
Or extract the mesh from the asset ?

by user 224464722878005248

It uses the mesh doesnt it?

Multiple meshes in fact

by user 224464722878005248

by user 224464722878005248

Have you tried just adding a field for the navmesh agent to your C# component and then use the serializer to export it?

You can use codegen too if you match the type name or use //@type UnityEngine.NavMeshAssetType above the typescript field (not sure about the full name here)

Then you should get the data from Unity. Not sure what the format is tho

Oh yes, I tried to serialise it but I failed, I will try it and watch what’s in there

by user 224464722878005248

Failed how?

To add a field in my custom component to get the Nav Mesh in my script to console.log it

by user 224464722878005248

I forgot that the //@type exist

by user 224464722878005248

Yeah you can always also write a c# component by hand or add stuff outside the codegen guards (// NEEDLE_CODEGEN_END) or extend the partial class elsewhere

there’s an example in the docs for that too

Does it work? :slightly_smiling_face:

Nop, I tried to load the NavMeshData as a mesh to use this function :

// Initialisation of pathFinding
        const pathfinding = new Pathfinding();
        const pathfindinghelper = new PathfindingHelper();

        const ZONE = 'level1';
        let groupId;
        let navpath;
        pathfinding.setZoneData(ZONE,     Pathfinding.createZone(this.myNavmesh?.geometry));

But the geometry of the NavMesh seems to be empty

by user 224464722878005248

by user 224464722878005248

So it generates an error

by user 224464722878005248