Problem - player networking lags

hellow everybody.

i got really annoying problem for all multiplayer scripters.

i GOT LAGS BUT! let me explain, when i’m connection to my room that i created, everything (player, Environment) moving smoothlly without stucks (Blasts),

but when my friend connecting to my room too, still my Environment and my player movement are good(nothing got stuck or laggy), but my friend’s player moves stucky and laggy,

just his player is laggy, the another stuff are moving smoothlly and fine.

WHY IT’S HAPPEN :?

This is happening because you’re hosting it, and thus you have immediate connection speed. The reason it’s not lagging for you is because your computer -can- handle the processing, but your internet signal (or your friends, or both of your internet signals) aren’t good enough, for whatever reason. This likely has nothing to do with Unity, and more to do with your friend (most likely) needing a better connection speed.

Connection speed truncating can be due to a number of things:

  1. Modem/Router quality- A bad modem/router (or both, at the same time) can severely limit connection speeds.
  2. ISP - Certain ISPs (Internet Service Providers) or even ISP packages (i.e. how much speed you decided to pay for, with your ISP) can have significantly higher or lower speeds than others. For example, if your friend, or whoever owns the house they live in, decided they wanted dialup (I don’t know of anyone who supplies dialup, anymore, but… anything’s possible :P), that would be why.
  3. Running too many online processes- your friend may be running a ridiculous number of programs in the background, apart from your game, such as web browsers and download managers, or even other online-games. Based on your knowledge of networking, I wouldn’t ignore this distinctive possibility…

@DESTRUKTORR is right, but it’s not necessary a specific problem of your or your friends internet connection. The internet or all networks in general have latency. Here we have another general confusion what “speed” means. Actually there are two different “speeds” which are essential two different things.

  • Bandwidth! The bandwidth of your connection specifies how many bytes you can send / receive per second. This is mostly important for big amounts of data and influences how long it takes until you completely downloaded a big datapacket.
  • Latency also known as “ping”. The latency is the time a single packet needs to arrive. A packet isn’t immediately on another computer. It always takes some time until it arrives on another peer. This depends mainly on “the distance” it has to travel and “the way” it takes. The internet consists of a network of thousends of routers. A packet might take any route through this web of router nodes. This route can change for each packet you send. This depends on the load of a router node and if it’s online / functional.

For “realtime” network games the amount of data per sec. is usually very small (unless you play an unoptimised mmo :D). The main issue is the latency. Usually in your own country you get values between 6ms - 70ms depending on your location relative to the server location and through which ISP you and the server is connected. Connections to other countries usually get worse because of the longer physical distance and the longer routing chain. If an ISP is overloaded because it can’t handle the amount of data for all it’s users, the latancy can increase because packets might get delayed a bit.

So far for “the reason”. As a solutions there are many techniques out there. One of the simplest is to transmit the player speed and direction in addition to the position. That way the other client can “predict” where the client will be by additionally simulating the movement on the local PC. When a position update arrives the player object is much closer to the actual position.

Another very common way is to delay the simulation of the other players a little bit (at least the latency time) and interpolate the clients position locally between two known position from the past. This gives you perfect smooth movement, but it doesn’t represents the most actual position. This technique is used by most fast-paced FPS games like Quake3 / Quakelive or source engine games (HL2, TF2, L4D, …). This is not so trivial to implement but provides the best visual results.

No matter what technique you use you will always have some delay since the world doesn’t work immediate bacause there is something like Causality :wink: