Recast is not defined?

Hello im trying to use Navigation Mesh to create a movement like league of legends. And im getting a bug.

<< Uncaught ReferenceError: Recast is not defined >>

I don’t really know how to fix this bc its my first time using it😅.

If you guys could help me.

<>

import "@babylonjs/core/Debug/debugLayer";
import "@babylonjs/inspector";
import "@babylonjs/loaders/glTF";
import * as BABYLON  from "@babylonjs/core";

import "recast-detour";



export class MainGame{

    private playerMesh;
    constructor(scene:BABYLON.Scene){
        
        let navigationPlugin = new BABYLON.RecastJSPlugin();

        var parameters = {
            cs: 0.2,
            ch: 0.2,
            walkableSlopeAngle: 35,
            walkableHeight: 1,
            walkableClimb: 1,
            walkableRadius: 1,
            maxEdgeLen: 12,
            maxSimplificationError: 1.3,
            minRegionArea: 8,
            mergeRegionArea: 20,
            maxVertsPerPoly: 6,
            detailSampleDist: 6,
            detailSampleMaxError: 1,
        }; 
    
        this.playerMesh = BABYLON.MeshBuilder.CreateBox("player",{size: 1,height:1}); 
        let groundMesh = BABYLON.Mesh.CreateGround("ground", 6,6,2, scene);
        navigationPlugin.createNavMesh([groundMesh], parameters);
    
        let navmeshdebug = navigationPlugin.createDebugNavMesh(scene);
        var matdebug = new BABYLON.StandardMaterial("matdebug", scene);
        matdebug.diffuseColor = new BABYLON.Color3(0.1, 0.2, 1);
        matdebug.alpha = 0.2;
        navmeshdebug.material = matdebug;
    }

    async enableRecastJSPlugin(){
        const recast = await Recast();
    }
}

I have created this function enableRecast… and i get a error too on await Recast
<<Type has no call signatures.

@Cedric

Ping @Cedric

@Cedric

I’m not an expert with package import. Do you have something in the logs?
@RaananW is the king for dependencies debugging

No i dont have anything i just installed library recast detour

Can you share your project?

I think you need to use the import statement to import Recast, or it will not be available when you try to await Recast();

1 Like

ive done it

import "recast-detour";

its on my github
Github repo link

I’m taking a look.

2 Likes

ok thanks

I’ve found this thread btw: Ammo with BabylonJS & Angular - #11 by sebavan

It’s the same mecanism between Ammojs and Recast