Error loading scripts... in PlayCanvas source code

client - playcanvas : PlayCanvas | HTML5 Game Engine
server - github : GitHub - jungle-escape/jungle-escape

Hello. I am writing this post because I am encountering an error that is difficult for me to resolve. Firstly, I am developing a multiplayer game and am currently using PlayCanvas - PlayNetwork. As the number of entities on the map has increased, I am attempting to solve this issue by adopting the traditional method of disabling the previous level and enabling the level ahead when passing a certain point, and I have created the following code.

Code at editor(client), server :

// Enable P3, Disable P0, P1
// Must be located in P2

var Enabledisable1 = pc.createScript("enabledisable1");

// initialize code called once per entity
Enabledisable1.prototype.initialize = function () {
  this.entity.collision.on("triggerenter", this.onTriggerEnter, this);

Enabledisable1.prototype.onTriggerEnter = function (target) {
  if (target.tags.has("player")) {
    const level ="Level");
    const p3 = level.findByName("P3. Rbtree");
    const p0 = level.findByName("P0. Start_Bedroom");
    const p1 = level.findByName("P1. Hello World");
    if (p3) p3.enabled = true;
    if (p0) p0.enabled = false;
    if (p1) p1.enabled = false;

Enabledisable1.prototype.swap = function (old) {"triggerenter", old.onTriggerEnter, old);
  this.entity.collision.on("triggerenter", this.onTriggerEnter, this);

When this code is applied, the moment the Leave button is pressed, an “Error loading scripts …” message appears. However, it seems that the problem occurs within the source code of the PlayCanvas engine. Although I plan to spend time trying to resolve this issue on my own, encountering an error in the engine’s source code is a first for me and I am feeling quite lost, so I am seeking help. Could you possibly provide any assistance in resolving this issue?

post the error message when running with the debug engine, that would be more useful to inspect.

1 Like