Pong tutorial error after publishing

Hello everyone, I just started using playcanvas by following the tutorial on the playcanvas youtube page but I am getting a weird error when I publish the app that I created.
When I launch the game from the Editor it works just fine. I can move both the players and its perfect but when I publish the same thing suddenly its like Player1 doesnt exist and I get this error in my console.

This only happens when I publish it. Like I said when I launch it from the editor it works perfectly.

The error points to this the first two if statements in input.js

if(app.keyboard.isPressed(pc.input.KEY_W)){
this.bats[0].script.bat.moveUp(dt);
}
if(app.keyboard.isPressed(pc.input.KEY_S)){
this.bats[0].script.bat.moveDown(dt);
}
if(app.keyboard.isPressed(pc.input.KEY_UP)){
this.bats[1].script.bat.moveUp(dt);
}
if(app.keyboard.isPressed(pc.input.KEY_DOWN)){
this.bats[1].script.bat.moveDown(dt);
}

Hi there. I just ran this build and it was fine. Did you fix this already?

No it still doesn’t work for me. Same error:
Screenshot

Tried running it on my roommates pc same thing happens.

Looks like there is a bug in the way we order Entities when we publish.

You have two Entities called Player1 and Player2. When you launch from the Editor the code app.root.findByName("Player1") is returning the bat Entities. When you publish this code is returning the Goal Entities. To work around, I’d suggest renaming one set of Entities so there is no confusing. In the meantime, we’ll fix our bug.

Sorry about that.

1 Like

Tnx for the fix works now! :smile: