Problems adding collider in create() / delayed player creation

I have a multiplayer game where the this.player is loaded AFTER socket.io connection is completed and I can’t do
this.physics.add.collider( this.player, this.collisionLayer)
in create() as the this.player object was not yet created when create() is over.

How do I wait for this.player to be completed so that I can add collider in create() ?

I tried putting this.player.create(this.character) in preload() or create() and still the same results …

Adding this.physics.collider() in update() causes the CPU to go up really high…

Any suggestion on how to fix this ??

Can you do it at the same time you create the player sprite?

Thanks, let me try this …

I removed ALL the collision in update() and only left the movement ( up,down, left & right) and found that the CPU is still very high

Is there a way in Phaser or Chrome browser Developer Tools to find out which Phaser engine is using too much CPU or memory ???

Does the rendering causes the CPU to goes up with a larger maps ??
I even tried removed ALL the layers except ground layer with nothing on them … ?

In dev tools you can record a timeline (or whatever it’s called) and see the top functions.

I did a quick 60 sec record, most of the CPU was related to Animation Frame Fired
How do I limit the rendering or fix this ??

The Phaser is being called from Vue2 with a top navbar and sidebar … does that affect the high CPU usages ??

Sort by Self Time.

I did a recording of same 60 secs sorted by Self Time…

I’m not sure what to make of that reactiveGetter. Try Total Time again, and show a long list?

Here are the Total Time list…

My map size is 120 x 120 tiles, each 32x32 pixels …

You may just have a lot of tiles to render. I don’t know why reactiveGetter looks so busy.

Thanks, let me load the SAME map without starting it from Vue2 …

Found the issue, bcos I added this.physics.add.collider in update(), it slows down the FPS and eat up a lot of memory until it ran out of memory errors and crashed.

I fixed it ( a lot of trial and errors ) by using events, once the player with socket.io load is completed, I emit an event to trigger the on event to load the collision

this.events.on('playerLoaded', this.enableCollision, this)

Closing this …