Lagging multiplayer problem

Hi guys,i tryed to run the multiplayer of the game and i am having problems,there are 2 players and 1 disk,everytime a player hit the disk the ownership of the disk change.When i am the owner of the disk the gameplay is perfect and there is 0 lag,but than when the other player hit the disk the movement of the disk is “lagging” and the gameplay is not good to play,here there is a video of the gameplay

.

  • Do you think it is a client-prediction problem?cause the movement of the objects when i am the owner is perfect and there is not input lag

Instead of changing ownership every time you hit the disc why dont you just calculate the correct position on the server/host and replicate that on clients?

1 Like

In a Host/Client 1:1 game the Host will always have the advantage of zero lag. Competitive 1:1 games should have an authoritative server instance so both players have the same handicap or at least would have if they had the same ping to the server.

1 Like

i could also try it,i was doing the changing ownership cause it was more intuitive,so you are saying that when the client hit the disk i should send a server Rpc and change the position of the disk?

The fact is that when the client has the ownership of the disk the game is not lagging from the view of the client.
In this case the client-prediction doesn’t help correct?

Updating,i changed the code and now there is not the passing of the ownership when a player hit the disk.
I removed the Network Rigidbody component from the disk cause it became kinematic and for that reason the disk didn’t move.
Now when i am the host everything works great,the movement of the disk is perfect when i hit the disk and when the client hit the disk.
But when i am in the view of the client the things are bad,the disk is constantly lagging when i hit the disk and when the host hit the disk,it is like the host doesn’t manage to keep updated the position of the disk.
Do you thing this could be the problem? How can i solve this problem?

You should read this.

https://www.gabrielgambetta.com/client-side-prediction-server-reconciliation.html

1 Like

I also implement the Network rigidbody on the disk and the situation not changed a lot,the Network Rigidbody seems to be exacly what i was looking for.
Why the gameplay doesn’t change after have implemented this component?

8997109--1239277--qdqd3w.PNG

While this example doesn’t address all potential issue regarding lag (and the like), I figured it might help you resolve the issue with your puck. When you finish your game let me know… I love air hockey! :slight_smile:
Just create a stand alone build and run a couple of instances. One as a host and the others as clients.
Make sure that the host is selected (the “host” text will be fullbright red like the host’s player color) and hit the space bar to cycle ownership of the “follower” ball that is using an owner/client authoritative NetworkTransform so that the newly assigned client owner controls the “follower”. For fun I apply impulse force to the ball.


You will notice a “transparent” purple-blue ball and then the “visual” aspect which lags slightly behind it. The “transparent” purple-blue ball is the actual NetworkObject with the NetworkRigidbody and NetworkTransform (set to owner-client authority) and the ball with the material is the “ghost” client representation.

The basic idea is to separate the “visual” portion from the actual NetworkObject itself for this type of scenario where you could have “gaps” between changes in ownership due to interpolation and the time delta between clients. I didn’t do a full blown client prediction system, but it provides a reasonable end result.

With the puck, you could still run into some gaps between collision and the visual part which that depends upon the collider and who is detecting the collision.

As opposed to changing ownership when the disk is hit, you might consider changing ownership when the disk crosses the middle of the table coupled with something like the splitting of the visual and the NetworkObject itself you might see a better end result.

9261783–1295883–OwnershipChangeOwnerAuthority.zip (23.7 KB)

thanks man,sorry for the waiting,i just hired a person to write for me the client-side prediction