How I'm planning to fix lag

the first optimization

I will be posting more things here, about lag, but this is the first optimization I’m making.

And it actually might be game-changing.

expected improvements: ping, fps

In swordbattle, every single player is being updated 60 times a second.
Even for a computer, this is a LOT.
Also, a lot of unnecesary data is being sent over the network 60 times a second
Stuff like your skin, name, coins, don’t need to be refreshed tons of times a second.

The first optimization will improve this, by only updating players close to you.
That is, people who are far away from you won’t be updated.
Now for you, the player, you won’t notice anything, because you won’t see them!
But for the computer, this is a lot of strain taken off.

This will improve FPS, because players away from the screen won’t be shown.
It will also improve Ping, because less data is sent over the network causing less lag.

Now, if you ACTUALLY understand what this means, you might ask…
How will the minimap and leaderboard work, if people far away isnt being updated

Good question, i will have to rewrite how the leaderboard and minimap work, but essentially
If a player is far away from you, data about them will still be sent
It will just be much less data, and at a much slower rate.
Instead of sending it 60 times a second, maybe 2 or 3 times a second.

Side effects,
Since the minimap and leaderboard will be updated so slowly, it may look like the minimap is glitching
This is normal, and it can be fixed using interpolation, which is planned for later.

This is my first optimization and I will update here once it’s in the game!
Most of the code for this is finished and so It will be added tonight.
Hopefully this makes a dent in the lag issue.

3 Likes