If an object is moving at relatively fast speeds, and the network ownership is with different clients in the game, there is bound to be disparity in the position of the object between different clients views due to latency.
My question, if I were to transfer the network ownership suddenly, the object would obviously appear to teleport. Is there any way to mitigate this?
depending on what theyâre trying to move, clients can render whatever object he wants to move independently while achieving the same goal. It is better to calculate the movements on the client instead of the server
If you donât mind the potential risk of exploiters being able to influence physics, just set the objects network owner to a single client.
This will make physics really smooth for that one player.
As long as network owner doesnât change, other players should be able to predict the physics on their clients, pretty sure this was added into Roblox not long ago.
Experiment and see what works for you, consider this a starting point.
You can improve and make it less exploitable later, focus on the implementation and getting it working first.
Iâll give some context perhaps. Itâs a ball, in a football (soccer) game.
I canât give network ownership to only one player, I want it to be relatively smooth for everyone ingame, without having input lag or such. I donât care about exploits.
In that case you will likely always have some input lag.
The average player will maybe have about 100 - 200 milliseconds of lag which is like 1/10th of a second to reach the server and another 1/10th of a second for others to see it assuming everyone has roughly equal ping.
If everyone had about 100 ms ping, you could theoretically update the ballâs position like 20 times a second which is faster than you think and acceptable (ping is the time it takes for info to go back and forth, not just forward and the ball only has to replicate forward when itâs moving on the server).
I donât know if setting the network owner to nil will do anything since that might set it to automatic.
You could utilize Robloxâ new shapecast (thicc raycasts) and script a simple ball projectile that just rolls and moves around on the server (no physics but through teleporting super short distances, multiple times per second).
On the client you can use TweenService or manually implement a method to predict and smoothly interpolate/animate the ball as it moves around which might not always be 100% accurate but should be good enough in most common cases.
I donât want to separate client simulation and server simulation for the inaccuracy, the accuracy is needed.
I just need some way to make it so that the network ownership change (currently the person who last hit the ball has network ownership) isnât too rough.
There will always be some inaccuracies no matter how much you try to eliminate that problem.
Itâs the nature of online multiplayer with latency.
Most important part is that the ball moves if the player hits it and thinks they hit it.
Donât worry about it being a few inches off from what other players see because this happens all the time in games but is cleverly disguised with visuals and rough predictions and estimations.
Youâd have to make your game singleplayer to eliminate all of these issues which would ruin the point of a multiplayer game in the first place.
Roblox physics already seem to be working fine for most things. Itâs about as good as physics in multiplayer can get without being computationally expensive and causing other problems.
(Donât quote me on that, some engines do have better physics but Iâm not here to compare physics engines right now, this is Roblox weâre talking about.)
I donât want to change the approach I have atm, I only want to mitigate the network ownership change being too rough, there surely has to be a way that makes it better?
Unfortunately as far as I know, no.
Changing network ownership will always have a bit of a hitch.
But since it results in the ball teleporting back a short distance, you could try teleporting it forward to make it a bit more seamless.
But you will always have a hitch or some choppiness unless everyone has a perfect online connection with little to no ping.
You just want to âeaseâ the ballâs movement when the ownership changes?
Try measuring ping by sending messages back and forth between the server and client, use that ping to teleport the ball forward a X amount of studs so the hitch is less noticeable.
If you want to take the extra mile, make the real ball invisible and use a âfake ballâ that has no collision and simply always moves and interpolates to the real ballâs location.
The interpolation would look wacky. I could already disable hits before network ownership change, interpolate it and then enable hits again, but feel itâll just look weird, the ball will basically look like itâs moving on its own.
Try measuring ping by sending messages back and forth between the server and client, use that ping to teleport the ball forward a X amount of studs so the hitch is less noticeable.
You interpolate the fake ball to the real ballâs location in a RenderStepped event using RunService.
You can of course adjust how fast it interpolates and it shouldnât look yanky.
You can measure ping by firing a remote event to the server and waiting for the server to fire one back to the client.
Measure the time it takes from the moment you send it and end the timer the moment you receive the signal.
The time it took for the signal to travel back and forth, thatâs your ping.