A four-part tutorial series covering making online...
This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.
Consider the following problem: player A is standing still and aiming at player B, who is running to the right. Player A hovers the mouse exactly over player B and shoots. (Assume the shot is instant-hit, like a laser or infinite speed projectile.) The message to the host indicating they are shooting takes 100ms to get there. During that time, player B keeps moving to the right. The host receives the message 100ms late and tests for a collision where player A is aiming - but they miss, because player B has moved on! Player A saw themselves give a direct hit, but they never caused any damage.
In general, the host sees each player do everything a bit late because of their latency, and players end up missing moving targets. This kind of issue will infuriate players, who eventually learn that they actually need to aim for the empty space ahead of where the player is moving. This is not very realistic or fair. Lag compensation is a technique to avoid this result.
The host knows how far behind each player is seeing the game, because it is measuring everyone's latency. So when the host receives the message indicating player A is shooting, it knows they actually did that 100ms ago.
The host is remembering the past few seconds of each object's history. It can then look back and see where player B was 100ms ago. Then it can test if player A scored a hit on player B at the time they originally fired. This is how the latency of player A is compensated for by the host, and it means player A likely scores a hit on the host when they see themselves score a hit on their own screen.
This creates another problem though. Player B is on a delay as well. If they have a 100ms latency, then the host is moving them about 100ms behind where they see themselves (remember their local input prediction moves them straight away). On top of that, the host is moving them further behind when testing for a collision when player A fires.
This means player B sees player A aiming behind them where they would miss, firing, and then they get hit anyway! In extreme cases player B may have in fact reached shelter from player A so they can't be directly hit, and then they suddenly take damage. This is annoying for player B, but is usually not as bad as having no compensation - at least players actually have to aim directly at each other to hit. A common solution is to not clearly indicate where players are aiming, so player B can't easily see player A appears to be aiming behind them, making it look more acceptable when they are hit.
Hi.I have a question : I made a chatroom. but only when host and peers internet is same,It works.
I ask it in the chatroom tutorial but you said I must see here
but I cant understand it.
can you help me?
See the section on connectivity in this tutorial. You might need to run a TURN server to get connectivity between every combination of networks.
Hello! I managed to make the multiplayer connection, but I'm having a problem with the peer, on the screen of his monitor the player's jump is not well synchronized, you know how to fix? Sorry for my english, I'm Brazilian and translated by google translator!
I hope you went to the forums, because it's been a year.
Now it's been two
and now 3
Hi.How can I get TURN server??????
answer: learn how to get TURN server thank you
Hi.How can I get TURN server??????
idk bro figure it out urself
IT would be great if we had a tutorial on how to use a TURN server