cs6413110 / Pixel-Tanks

0 stars 2 forks source link

Why Game Lag Spikes #486

Closed BreadSpam closed 2 months ago

BreadSpam commented 2 months ago

Details

first of all, bullets and explosions take a long time to process when in large quantities, due to the amount of math needed to make them accurate. this is kinda like why mc lags when u place 1000 TNT, or 1000 entities. game slows bc huge amount of data.

what would be desirable for game, is so that any normal activities would not slow down the game like this. sadly, this is false, because when the servers are dying, such as in the lunchroom, even a normal amount of bullets and explosions can cause slowdown

this is a huge problem because our game currently just accepts the slow process rate and does it as normal despite the amount of things. for example, lets say, 10 bullets at once, starts the slow down. if the person keeps firing, the bullets will overwhelm the game and it will get exponentially slower (/nuke doesn't break game forever bc its only temporary)

this normally isn't a problem bc ppl have internet speed and real servers, but we don't, so there is a few things we can do:

1: make bullets/explosions less resource hogging. this would hopefully make it take more bullets in order for the slow down to start

2: better catch up. basically, make it so if the game is overwhelmed, then just either have super simple code to help the game reach normal speed again, or despawn certain things to make game run normally (for example, skipping the step in a frame to load the bullets)

3: less bullets/explosions? make code that will determine the max bullet count based on how gud the ping/tps of the server is. then if doing something such as spawning a bullet or explosive wuld take it over the limit, then just don't spawn it. this would help in the scenario of "the guy who keeps firing" bc now he cant :)

4: lowering game quality. making game engine run worse to help game catch up (les TPS, FPS, and etc to help ping exist)

BreadSpam commented 2 months ago

just add this instead of whatever lag update u were doing before. this would actually fix the lag somewhat, not "reducing chunk loading" nonsense that is just wasting time :(

DarkMemeGod411 commented 2 months ago

why am I assigned

cs6413110 commented 2 months ago

ok coding

tick() {
  for (const type of ['pt', 'b', 's', 'd', 'ai']) for (const entity of this[type]) delete entity;
  //...
}
BreadSpam commented 2 months ago

lol, um sor???? I meant only bullets not everything :Ahukdhjkdasf

cs6413110 commented 2 months ago

This entire issue isn't accurate. Closing.

BreadSpam commented 2 months ago

ok then fix lag update