kevinshen56714 / SkyOffice

Immersive virtual office built with Phaser, React, Redux, PeerJS, and Colyseus.
https://sky-office.co/
MIT License
930 stars 289 forks source link

MyPlayer frozen when Game scene restart or reloaded #45

Open loveomg opened 2 years ago

loveomg commented 2 years ago

Hi everyone~ I am really happy to know this great project

Nowdays I am making custom maps for Skyoffice Its very easy to make new maps and load them into Skyoffice

But whenever I load new maps or restart Game scene, MyPlayer frozen.. I can't move my avatar It caused by previous MyPlayer collider and other colliders I tried hundreds of way to remove old colliders unfortunately, it failed...

Bellow is my codes for restart Game scene from MyPlayer.ts

this.scene.input.keyboard.resetKeys()
this.scene.input.keyboard.shutdown()      
this.scene.physics.world.colliders.destroy()  

//this.physics.world.removeCollider([this.myPlayer, this.myPlayer.playerContainer])
//this.physics.world.removeCollider([this.myPlayer, this.myPlayer.playerContainer], groundLayer2)
//this.physics.world.removeCollider([this.myPlayer, this.myPlayer.playerContainer], vendingMachines)
//this.physics.world.removeCollider([this.myPlayer, this.myPlayer.playerContainer], gameMachines)
//this.physics.world.removeCollider([this.myPlayer, this.myPlayer.playerContainer], doors)

this.scene.scene.stop('game')
this.scene.scene.restart( {
    network: network
})

How can I make my Avatart works after restart or start again?