Ssatguru 's Character Controller

Hello , guys,
Regarding this amazing package , im following the quick start guide at:
quick start
But ,Im having some problems instantiating the characterController class.
So , as quick start mentioned, I did:

npm install babylonjs-charactercontroller

Then imported on my script:

import {CharacterController} from "babylonjs-charactercontroller";

But when I need to use this class by calling its constructor like:

const cc = new CharacterController(player, this.camera, this.scene, agMap, true);

It yelds a huge error messages, like:

X [ERROR] Could not resolve "babylonjs"

    node_modules/babylonjs-charactercontroller/dist/CharacterController.js:1:93:
      1 │ ...peof module)module.exports=i(require("babylonjs"));else if("function"==typeof define...
        ╵                                         ~~~~~~~~~~~

  You can mark the path "babylonjs" as external to exclude it from the bundle, which will remove     
  this error. You can also surround this "require" call with a try/catch block to handle this        
  failure at run-time instead of bundle-time.

Any ideas ?
Im using vite as starting script.
Leandro.

Hello!

You have to install babylonjs as well.

https://doc.babylonjs.com/setup/frameworkPackages/npmSupport

https://doc.babylonjs.com/setup/frameworkPackages/es6Support

1 Like

thanks !!!

1 Like