Scene change not functioning properly

Hi all,

In my game, the scene is supposed to change upon one entity colliding with the other.

There are a number of problems with this.

  1. The collision needs to happen twice for the game to switch scenes.

  2. The scripts for one scene are acting in the other scene and are causing errors.

  3. When the scene reverts to the original, the sky box isn’t there, and there are major problems with playing the game.

Code Link is as follows
https://playcanvas.com/editor/code/579353?tabs=14753448

Valid scripts are collider.js and number MANAGEMENTSCR. js

Please help!

I had kind of the same problem (or atleast I think I did). I am guessing you’re using the tutorial provided by PlayCanvas to switch scenes? The thing is, that Switching scenes is additive. I had to first destroy the old hirarchy and then load the new one in order for it to work properly, especially, when using same scripts/events in your other scene.

    var oldHierarchy = this.app.root.findByName('Root');
    oldHierarchy.destroy();
    this.app.loadSceneHierarchy(this.sceneId);

I have no idea what’s going wrong with the collision tough, can happen sometimes, maybe some Rigibody component is not enabled correctly I don’t have much experience with the collision system

Thanks a lot @Bfischlin, I’ll implement the code above in my scripts and see if it works, and get back to you about the result. Meanwhile, could you please also help me with the skybox problem(point no. 3)?