Another problem with switching scenes

Should I do something like this?

var sceneItem = app.scenes.find("Scene Name");
app.scenes.loadSceneHierarchy(sceneItem, function (err, entity) {
    if (!err) {
        var e = app.root.find("My New Entity");
    } else {
        // error
    }
});
app.scenes.loadSceneHierarchy(sceneItem, function (err, entity) {
    if (!err) {
        var e = app.root.find("My New Entity");
    } else {
        // error
    }
});
1 Like

Yes, I think so, give it a try, it’s free :slight_smile:

1 Like

Do you think I can destroy the previous root by accessing it as an attribute?

It still doesn’t work. You will need to find the error.

Thanks in advance

Office hours video here about this issue: https://www.youtube.com/watch?v=qw7tTG130F0 Jump to 04:04 for the answer

Fixed project: https://playcanvas.com/project/887027/overview/f-escape-the-lab

What Leonidas said earlier was correct :

The mouse event listener was not being cleared when the script/entity is destroyed so the callback is still being triggered.

2 Likes

Wow, thank you so much!

I wouldn’t have expected from you to make that effort and to explain it carefully.

What can I say except for “Subscribe”? ¯_(ツ)_/¯