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
0
Question by Chibiliplop · May 15, 2015 at 02:07 PM · networkgravitypredictionauthoritative

Network client side Prediction and gravity server-client different

Hi everybody. I'm making basic multiplayer shooter in 2D with model in 3D for my studies with a authoritative server . Actually i try to go over the client prediction to have smooth movement in the client-side. So what i basically doing is to apply the same movement logic in the client side while the server apply it's own movement logic and correct the client-side position with the server if there is too much difference. But i'm facing a big problem. The gravity is not apply on the same way in the server-side and the client-side i mean the client-side for example jump a little bit less than the server-side. And that apply a big desync between the two. I try to figure out what can happen and i think the problem is the frame-rate. I use a character-controller for the controller with my own implementation of the movement logic the script is the same for both client and server. So i try to understand how to be fully fps independent. Actually this is how i calculate the gravity movement.

 verticalSpeed -= gravity * Time.deltaTime; // apply the gravity
 Vector3 movement = new Vector3 (
             horizontal * trotSpeed, 
             verticalSpeed, 
             0);
         movement *= Time.deltaTime;
         collisionFlags = character.Move(movement); // apply the movement

What's wrong with the short part of code why the server jump a litle-bit more than the client. Did i make a big mistake on the way i calculate my gravity ?

Thanks in advance for the response.

Comment
Add comment · Show 5
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 Yubi · May 15, 2015 at 06:01 PM 0
Share

How did you cope with the latency between client/server?

avatar image Chibiliplop · May 18, 2015 at 09:12 AM 0
Share

Yubi for more explication i advice to reffer to this doc : http://www.gabrielgambetta.com/fast_paced_multiplayer.html http://gafferongames.com/game-physics/networked-physics/ https://developer.valvesoftware.com/wiki/Source_$$anonymous$$ultiplayer_Networking

For the movement the lag compensation is really easy just save all the position after the movement command in a circular buffer. and when the server send the response check if both have the same result. If they don't have the same result rerun all the simulation (in accelerate) from the last known server position.

avatar image Yubi · May 18, 2015 at 10:03 AM 0
Share

Yes I understand how it works, but I expected the problem you are seeing might be related to latency. But I see you have investigated that already. $$anonymous$$aybe you have somewhere any rounding problems, e.g. with floating points?

avatar image Chibiliplop · May 19, 2015 at 09:08 AM 0
Share

Yeah i look into the floating point and the problem with networking game during my research. And i think the major problem with my implementation is the difference between the frame-rate of the client and the server. I mean at the begining i was using update in both client. But if you take the jump example the frame when both detect the apex can be different of 1ms so one gonna be upper than the other. And is the same for walk if i push left for 1ms the player must move at walkspeed 1ms But if the frame take 2ms on server and 1.5ms on client. the server move : walkspeed 2ms. and the client move: walkspeed * 1.5ms so both will have different position. So the only way to solve that is to use the FixedUpdate so both have the same rate of frame while processing the movement.

avatar image Chibiliplop · May 19, 2015 at 11:41 AM 0
Share

Another probleme i'm facing right now is. The time between when the server apply the movement and when the server send the updated movement to the client. It take between 1.96sec and 2sec oO. it's really really slow why the networkview take so many time to sand the information ?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Chibiliplop · May 18, 2015 at 10:40 AM

Finally after more and more documentation about the client-side prediction and reconciliation. I success to avoid the problem by performing all the movement of the client and server in a FixedUpdate so both have the same simulation. If it's differ just rerun the simulation from the last know position of the server.

The next problem is how to implement the lag compensation with unity for the shooting. The rewind sound difficult with a raycast.

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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Infinite/procedural multiplayer world in Unity possible? 2 Answers

Clientside Prediction in the Networking Example 2 Answers

Client side prediction from the Networking Example 0 Answers

Network problem player lag/jump when move with autoritative server and interpolation/prediction 0 Answers

Trying to send command for object without authority. - change color of object from client 0 Answers


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