i’m following ‘Create a Navigation Mesh’ tutorial from official docs
But when i added the plugin and initialized it, i got an error that i mentioned in title.
Is there additional steps that i need to prepare before using the plugin?
import
{
RecastJSPlugin,
} from "@babylonjs/core";
let navigationPlugin = new RecastJSPlugin();
import {
MeshBuilder,
Scene,
Color3,
AbstractMesh,
SceneLoader,
ActionManager,
ExecuteCodeAction,
Mesh,
Vector3,
RecastJSPlugin,
StandardMaterial,
} from "@babylonjs/core";
import { Button, AdvancedDynamicTexture } from "@babylonjs/gui";
import Recast from "recast-detour";
And this is the part of my level code to set up navigation plugin.
public async SetupNavigationPlugin() {
const recast = await Recast();
let tempGround = MeshBuilder.CreateGround("test_ground", {
width: 10,
height: 10,
subdivisions: 20,
});
let navigationPlugin = new RecastJSPlugin();
navigationPlugin.createNavMesh(
[tempGround, this._outlineCollisionBox],
NAV_PARAMETERS
);
var navmeshdebug = navigationPlugin.createDebugNavMesh(this.scene);
navmeshdebug.position = new Vector3(0, 0.01, 0);
var matdebug = new StandardMaterial("matdebug", this.scene);
matdebug.diffuseColor = new Color3(0.1, 0.2, 1);
matdebug.alpha = 0.2;
navmeshdebug.material = matdebug;
}
But i still getting this error whenever i run the code.
Errors below:
“recast.es6.js:9 Uncaught (in promise) TypeError: Cannot set properties of undefined (setting ‘Recast’)
at recast.es6.js:9:565757
at Level.SetupNavigationPlugin (Level.ts:103:26)
at new Level (Level.ts:99:10)”
Is this a typescript-only issue, or does the js side not working as well without the “new”? If it is ts-only it might just be a declaration issue that can be easily resolved. If you can somehow reproduce it to me I can test it myself.