Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by CarbonTech Software · Jul 05, 2010 at 06:46 PM · rigidbodynetworkingoptimizationlag

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

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

5 Replies

· Add your reply
  • Sort: 
avatar image
7
Best Answer

Answer by Murcho · Jul 06, 2010 at 07:10 AM

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.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Agustin Petrini · Mar 25, 2011 at 10:18 PM 0
Share

$$anonymous$$urcho, I'm a little confused about this. The article you refer mentions 3 techniques: -Entity interpolation. -Input prediction. -Lag compensation.

What I understand you are saying is not doing Lag compensation neither entity interpolation, but something like input prediction with all entities. That would be, for example, execute AI code in the client in each tick and interpolate the result with the actual value received from the server. Is that how you did it ?

avatar image Murcho · Mar 26, 2011 at 01:39 AM 0
Share

The three techniques are mixed with one another. For players you predict based on input, for AI you predict based on what your AI rules are, and you interpolate/extrapolate your data from there, always adjusting once the server data is received. It's been a long time since I implemented this system so sorry if I'm a bit rusty with it.

avatar image
3

Answer by JRitchey · Nov 28, 2011 at 05:35 AM

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.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image JorgeMasiteli · Feb 08, 2012 at 03:46 PM 0
Share

that solved my problem. Such a dark trick! Thanks JRitchey

avatar image JRitchey · Feb 09, 2012 at 01:33 AM 0
Share

Anytime... The NetworkRigidbody script does the same thing they're talking about in the other answers (Dead reckoning and prediction). The Networking sample has scripts that do this for other types of objects as well.

avatar image oliver-jones · May 21, 2012 at 02:39 PM 0
Share

Hello, I'm having the same problem and I believe this is where my problem lies. Although, I cant seem to change my PrefabName(Transform) within the Network View by dragging the NetworkRigidbody script? What am I doing wrong?

avatar image andyspeak · Sep 02, 2013 at 11:35 AM 0
Share

worked for me ty man i had sum crazy problems till i found this

avatar image
2

Answer by qJake · Jul 05, 2010 at 08:21 PM

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image CarbonTech Software · Jul 05, 2010 at 08:51 PM 0
Share

Thanks. So there is nothing else I can really do? Would making the ridgidboy extrapolate decrease the lag better than interpolating it?

avatar image
-3

Answer by matthew 1 · Aug 13, 2010 at 06:58 PM

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Stardog · Mar 28, 2014 at 10:25 AM

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image fholm · Mar 31, 2014 at 07:31 PM 0
Share

Problem with this tutorial is that his examples are incredibly contrived and the solution he proposes doesn't actually work in a "real" game where a lot of things are going on at once.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Photon - Nothing Working!! Please Help (w/ Video) 0 Answers

Why does this simple follow script make my game lag? 2 Answers

Add 2d rigidbodies to moving objects to increase performance or not? 1 Answer

Unity network perfomance 0 Answers

How can I optimize my range tests? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges