liabru / matter-js

a 2D rigid body physics engine for the web ▲● ■
MIT License
16.86k stars 1.97k forks source link

Agar.io Style Game Laggin #338

Closed 253153 closed 7 years ago

253153 commented 7 years ago

Hello, I used Matter.js as the engine for my agario style game, but it starts lagging when I get 100+ players. Can anyone suggestion some practical tips for optimization for matter.js to reduce the CPU load?

liabru commented 7 years ago

I suggest using a profiler in devtools to try identify the functions that are taking up time.

I can't really give any particular advice without knowing any details of your implementation though. Is there a link to the game?

issy123 commented 7 years ago

If you are running matterjs in node.js: I highly suggest changing from the 'ws' npm module to 'uws'. This is one of the most cases why it lags (I for example had lag with 70 players, now with uws I can have 250+ players)

253153 commented 7 years ago

Thanks @issy123 indeed I am. It did seem to help but I am still having major lag issues. Any further help would be highly appreciated