How Do I Reduce Lag in my Networked Game?

Hello, right now I have an operational networked game - but one that is plagued by an enormous amount of lag. In the game, you basically are a car that can shoot other people (who are also cars).

I have set the rigidbodies to "interpolate" and the Network Views to "Unreliable" with little to no effect.

Is there anyway to reduce the lag further?

Sincerely, CarbonTech Software Admin

The best technique I've found is to use a prediction system. The basics of which are to have a local version of the actors that the local player can see, and an invisible version which is linked as closely as possible to the server data.

The local visible one is updated based on local input, so it predicts where the server will tell it to be. Then when the server sends back a message telling the actor where is should be, the invisible one is moved immediately to that point, and the visible one is smoothly interpolated to that point.

It's a tricky system to implement, however it is (in my opinion) the best way to do things. The Source engine uses this system in all of it's multiplayer games (Counter Strike, Team Fortress 2, etc.). Here is an article on their wiki explaining how they do it.

EDIT : Note that while this won't directly change lag, it will change the way the player perceives the lag. You should still try to optimize the amount of data being sent.

If you are trying to use the same NetworkRigidbody.cs script as the Network example, there is a small detail you may have overlooked. I got lucky in finding it in an out-of-date Unity Tutorial.

All you have to do is change the ‘Observed’ field in ‘Network View’ on your prefab from
‘PrefabName(Transform)’ to ‘PrefabName(NetworkRigidbody)’ by clicking and dragging the ‘NetworkRigidbody(Script)’ component into the ‘Observed’ field.

This solved my lag issues.

The only thing you could do, besides optimizing what you send over the network (which you have to do, we can't help you with that), would be to increase the Sendrate, found in Edit > Project Settings > Network.

From the UT docs:

The data that is sent at the Sendrate intervals (1 second / Sendrate = interval) will vary based on the Network View properties of each broadcasting object. If the Network View is using Unreliable, its data will be send at each interval. If the Network View is using Reliable Delta Compressed, Unity will check to see if the Object being watched has changed since the last interval. If it has changed, the data will be sent.

This tutorial shows interpolation and prediction of a Rigidbody:

http://www.paladinstudios.com/2013/07/10/how-to-create-an-online-multiplayer-game-with-unity

Question is already answered, but the tutorial is great.

sometimes your signal will go bad so if you have wireless internet server just disconnect and connect again and if that dont work and the lag is incredably slow i would contact your internet provoider for ore info.