SOLVED Massive lag in multiplayer

Hyteel

Member
Hi I have been working on a multiplayer system for awhile now and decided to make a server based system where the calculations are being handled by the server. This has caused the lag and response time of the game to drastically increase and I can handle collision server-side this way. But after around a minute of walking around it becomes slower and slower until it becomes unplayable.

I am handling the positions and calculations of all the players through the use of a ds_grid and ds_list (I have only created one so it is not due to multiple ds_grids being created). That is why I suspect it has something to do with ds_grid. I looked at https://forum.yoyogames.com/index.php?threads/solved-lag-with-ds_grids.31088/ , but did not find a solution (His problem was probably not due to ds_grid) and I could not find any other examples so i decided to post here. I have never posted here so I apologize in beforehand if I posted in the wrong place.

Tldr: Server problem with lag, dsgrid probable culprit, ds_grid_set/ds_grid_get might cause it??

Thanks in advance!
 

TsukaYuriko

šŸŒ 
Forum Staff
Moderator
How many times per step are you performing said calculations? Note that due to latency, it is often unfeasible to perform the same volume of server-side checks as it would be possible on the client side... limiting server-side stuff to verification once a second or so goes a long way to minimize the performance impact, as chances are your server simply can't stay synchronized due to latency.

We'd need to see the code in question to provide more qualified advice.
 

Hyteel

Member
I see, right now I have gone with an approach that simplified looks like this:

Player: Sends if button has been pressed and which direction it should move [1]

Server: Calculates if it comes into contact with a collision tile-map and then assigns the post collision value to a ds grid. Then sends the values (X, Y) to the players

Player: Takes the values and asigns them to the correct spot in the clientside ds_grid.

Player oPlayer: Takes the values from the ds grid and asigns them to x and y

Player oSlave: Takes the values from the ds grid and asigns them to x and y (if the id of [1] is not the id of the Player that received from the server)

Should I send the entire server and clientproject? or just all the code?
 

TsukaYuriko

šŸŒ 
Forum Staff
Moderator
Please don't send entire projects - this makes it hard to isolate what's related to the issue being discussed. You know this best yourself, so only post the code that is relevant to the topic (isolated as much as possible).

From what you've posted above, I can see that your model pretty much waits for confirmation from the server every time the player does something? This will not work well in a client-server environment due to latency. The server should verify what the client does, not dictate what the client can do. Always verify on the server side before actually applying the effects of anything the client does on the client side, but let the client act in the belief that what it does is legitimate. Otherwise, you're up for a hell of latency that will render the game unplayable.

As in, do not handle collisions on the server side. That's too computationally expensive on a large scale and too affected by latency to be usable in real-time (as you expect it to be). Handle that on the client side, verify it on the server side once in a while (so that if someone noclips through a wall, you move them back, all while not killing your performance on either side).
 

Hyteel

Member
I see, thanks for the reply. Il just go back to doing calculations on the clientside, I thought it would be alot easier to handle collision and maps using the server, but it worked fine before when I had it on clientside
 
Top