Changing scenes crashes game

Hi @almish_subuk!

To change a scene, please use the method from your other topic.

Not sure why you create a new topic about this problem, but I think it’s related to events.

If you use an event, you have to make sure you clean up the event if you change the scene. Otherwise the system is still listening to the event, even if not everything for the event exist in the new scene, which result in an error.

I’m not exactly sure how to do this correctly, but based on an event in from you script it should be something like below.

// create event
app.mouse.on("mousedown", function () {
    app.mouse.enablePointerLock();
    this.shoot();
    console.log("initlal gjs0");
}, this);

// remove event
this.on('destroy', function() {
    app.mouse.off("mousedown", function () {
        app.mouse.enablePointerLock();
        this.shoot();
        console.log("initlal gjs0");
    }, this);
});