d3dc / react-godot

A React Component to asynchronously load the Godot Engine and bootstrap a .pck
56 stars 20 forks source link

TypeError: path is undefined #2

Open WillYuum opened 4 years ago

WillYuum commented 4 years ago

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:

d3dc commented 4 years ago

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.

WillYuum commented 4 years ago

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.

city41 commented 4 years ago

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.