[SOLVED] Switching back and forth between scenes

I actually mean this:

// Find the Scene Registry Item by the name of the scene
var sceneItem = this.app.scenes.find('Some Scene Name');

// Assume the old scene hierarchy's root entity is named 'Root' which is the default name
var oldSceneRootEntity = this.app.root.findByName('Root');

// Load the scene hierarchy with a callback when it has finished
this.app.scenes.loadSceneHierarchy(sceneItem, function (err, loadedSceneRootEntity) {
    if (err) {
        console.error(err);
    } else {
        // Scene hierachary has successfully been loaded
        oldSceneRootEntity.destroy();
    }
});

I wrote my script according to this example. This, combined with my supervisor’s instructions for using loadSceneHierarchy() made me think that this is the best way to go. Turns out i was wrong

This has issues that I described here: Loading Scenes | Learn PlayCanvas

In an older version of this page, I also had a helper script that avoided this problem using loadSceneData first.

I’ve also gone through similar issues in these videos:

1 Like

Its not old or deprecated API. The changeScene function was added to make the process of ‘changing scenes’ much easier for most people.

I think most people would assume that the rest of APIs are old if they were told that changeScene() is exclusively a new API. If the other APIs aren’t called new as the changeScene(), one would automatically think that the rest of the APIs of this subject are old.

Which is why on that page, the very first thing we sure and say to use is the changeScene function. If your instructor is saying not to use a function that makes ‘changing scenes’ as simple as possible, then that’s a problem with your course/instructor.

You’re right on that, that was the main reason i had this much difficulty for undertaking this task. It’s also due the fact that every programmer have a different way of doing things and when you ask assistance from two different programmers, the information they give you may conflict eachother as it happened in my case

I used the word ‘new’ because it was added recently and makes it easier to tell which API I’m talking about. The other API’s already existed and are therefore no longer ‘new’. My apologies if that made it confusing for some users.

1 Like

My apologies if that made it confusing for some users.

No need to apologize for anything, i just said that to explain why i got confused. It’s not a big deal

1 Like

I watched the first video but Albertos told me how to turn off the mouse event listeners on discord before i watched it. It’s good know that there are videos which cover this topic. Ppl who resort to this forum for help will see them this way