react-godot icon indicating copy to clipboard operation
react-godot copied to clipboard

TypeError: path is undefined

Open WillYuum opened this issue 4 years ago • 3 comments

I have added the godot game into my site using the example provided in the repo.

Godot version: 3.2.1 stable win64

image

Reproduce:

  • Added the game files in the public folder
  • Imported ReactGodot component and added the required properties(pck and script)
<ReactGodot pck={"./game/game.pck"} script={"./game/game.js"} />
  • added the directory the same way it's used in the example in the repo leading to get me the error in the image.

WillYuum avatar May 14 '20 00:05 WillYuum

Where is path consumed? Its not in that stacktrace.

Its part of godot's generated game.js, right?

It sounds like a version incompatibility. I would need to do what I mentioned in #1 and make a map of different configuration values for different engines.

d3dc avatar May 17 '20 01:05 d3dc

Ah yes, I am using Godot 3.2 and this could be reason for the issue. I think I'll try to put the directory manually from the package files for now.

WillYuum avatar May 23 '20 21:05 WillYuum

I hit this issue as well. I am using Godot 3.2.2. I was able to fix it with this in ReactCanvas.tsx

.startGame(pck.replace('.pck', ''), pck)

Godot's js seems to now be looking for a base name it can use to find the wasm file. In my case, my pck file is called index.pck and my wasm is index.wasm, so stripping off .pck enabled Godot to find my wasm file and start the game.

This is what my startGame looks like inside my index.js file that Godot generated

    this.startGame = function(execName, mainPack) {
      executableName = execName;
      var mainArgs = ['--main-pack', getPathLeaf(mainPack)];

      return Promise.all([
        this.init(getBasePath(execName)),
        this.preloadFile(mainPack, getPathLeaf(mainPack)),
      ]).then(Function.prototype.apply.bind(synchronousStart, this, mainArgs));
    };

Based on this error, I am guessing startGame used to be startGame(mainPack)

I am brand new to Godot, so I may be wrong here.

city41 avatar Aug 29 '20 03:08 city41