• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Development How are 3rd objects made in the multiplayer game?

duran can

Member
imagine that I only have players, 1 box, and a physics system in the game. If a player has a LAG (ping) and a player with a ping of 30ms pushes the box, the player with a 150ms ping will see the box in a different place. Therefore, it will not get caught in the obstacle. what is the best way to solve this? How do big games solve this?

Ekran görüntüsü 2020-10-08 191658.png
 

Binsk

Member
Note: I've never user GameMaker's physics system as I haven't had a need for it so, grain of salt here. Just throwing some thoughts.

Just some casual looking around and it seems an option is to have the server (or I suppose, the 'host' in this case) handle the absolute result of the physics. When a collision is made, for example, you grab the exact position of the player colliding and the object colliding with and send it back to the clients to calculate on their side. This way the calculations would always match that of the 'server' while still letting the client do the heavy lifting. Only problem here is if there is lag and a separate collision occurs shortly after then there needs to be a way to speed up the physics on the lagging user's side to bring it back in sync. I couldn't find anything in the manual about manually updating the physics system (just ways to change the update speeds). This may possibly work itself out since the 'correct' physics would always be on the server/host so any bits of lag would be fixed each time a collision occurred (as the positions of the initial collision state would be sent over). Still, I could imagine the possibility for player clipping in certain circumstances.

I would assume disabling physics on the client and just having the host do it all would be death in terms of the amount of data that needs to be transferred back and forth but is this a possibility for just re-sync purposes? Or maybe just send data over once physics objects have set into a 'resting' position to guarantee their accuracy? As said, just spitting ideas here, this area isn't my forté.

I stumbled across this document from 2004. I haven't read the whole thing but it may prove useful.
 

duran can

Member
Thanks for the idea. I can make a simple physics system for my server.
Somewhere, I read that while doing the Counter Strike game with the VALVE game engine, it took the firing time of the bullet and calculated the location where it would go and made a calculation that there might be a player who had lag. Accordingly, the position of a player with lag could be further on the server. In other words, the server takes pings of all players and calculates accordingly.


This system of course remains very high for me :). I'm not such a good programmer.

If player A push the box -100 on the x axis the box can go very easily to this server with 30ping, but if player B push the box +100 on the x axis at the same time and this server goes with 300ping, player B has never actually pushed the box on the server side,
since the box and player B will not have contact at all. it will be. I get confused thinking about :D
 

Mert

Member
Topic 1 : Lag compensation. There are almost tens of techniques to handle this. Better to read some posts about this. My friend has a good collection of articles about networking in here : https://github.com/MFatihMAR/Game-Networking-Resources

You can't simply reproduce a physics condition in games. Physics system may show differences in different platforms, systems etc.
You must do the physics tasks on your Game Server, then send the related information to clients. Downside of this is that Game Maker Studio is not efficient at server networking.
(You can write your own Game Server with nodejs, golang etc. and import the Box2D library into them; then make the calculations in there. In this case, you're absolutely okay!)
 

Yal

🐧 *penguin noises*
GMC Elder
Even given the same initial configuration, the physics system tends to deviate eventually on the same machine. You need to have a system to synchronize the simulation between all clients for all physics objects.
 

Gizmo199

Member
Couldn't you just have the actually box and collisions happen on the server and just update a dummy physics object with the servers collision object phy_position_x/y?
 

duran can

Member
Couldn't you just have the actually box and collisions happen on the server and just update a dummy physics object with the servers collision object phy_position_x/y?
I really have a box object on my server but that's not the point,
if a player with a low ping and a player with 400 ping, contacts at the same time, the player with a low ping will push faster the box, so the player with a lot of ping will never touch the box.
But the 400 pinged player will send information that the client has touched the box. Although actually not in contact with the box on Server side . So I think the physics system will never work properly.

After all, they both play the game at 60 fps on their own client. but some player has 30ms ping some player has 400ms ping. Therefore, a player will send the box faster, a player will send slower. But after the slow sender send, the box may not actually be there.
 

Gizmo199

Member
Well that's what I mean, dont have the point of contact on the client's end but in the server instead. So if the ping is late for one client it won't matter cause the server is the one dictating the position and not the other way around. Yeah the box might teleport magically, but idk how you can fix that really. Maybe you could try offsetting the collision box in the server that updates positions based on the ping of each player I suppose using delta time?
 
Top