I’ve seen soccer games that somehow make the network ownership transition super smooth and appear to have no latency at all, I was wondering how do people do this? Usually when you are transferring network ownership there is a small delay (especially for people with high latency)
Video showcasing instant network ownership switch:
Smooth network ownership can’t be really a think. For exemple if you set ownership from a laggy client, the server will also count the lag and reflect it to others clients. Best way to get the smoothest is to firstly have an optimised game.
I’m talking about like ways to make the transition between NetworkOwnership APPEAR smoother like ‘hacky’ ways to do it like visualizing it on the client or any workaround for this because I’ve seen games that do this somehow
Its probably always a client simulated ball that takes constant updates from the server. Physics can ironically be easier to perform lag compensation for because if you replicate the force and position accurately within consistent parameters, the physics engine will replicate it just fine for just about everyone unless a severe correction is needed. See Rocket League.
That is to say, there is no server ball at all. It’s just a serialized object that the server keeps track of and occasionally course-corrects if there’s major misalignment between clients.
I wanted to note: this is not a ‘hacky’ way to do it. It’s rather industry standard. ROBLOX just gives a false impression of replication due to their replication model allowing server visualization and automatically handling primitive lag compensation that usually you’d implement as a game developer yourself.
I would use raycasts to calculate the trajectory of the ball, and then make those same calculations on every client with renderstepped, and its going to be as smooth as it gets for each individual client
How do you ‘correct’ their positions if server physics will always be slower? Obviously running physics on the client will be very fast but will the server even be able to keep up with that? It’s just gonna be constantly realigning due to the slowness of the server
Also, on the topic of Rocket League, how much of the stuff that they say can accurately be done in Roblox (or is even needed in Roblox)? (such as inp Constantly sending updates on the server as fast as they say in the videos that explain their system, wouldn’t that just lag the server a ton? Also one final question, should server be authoritative in this system (since that’s what RL does)
You dont run the physics on the server is the point. You have clients send information on what they did to the ball.
I verify position by mathing it on the server from the last hit lets say at 30 times a second (30 hz). Clients send their data of where they think the ball is, and if any client sees it wildly off the mark, the current velocity, direction, and CFrame of the ball is delivered back to the desynced client.
Meanwhile, clients send information if they change the velocity of the ball, like kicking it or making contact. There are also other ways to do this and it depends on the game’s mechanics, whether its totally physics based or mechanic based (mechanic = a single input produces a discrete result, physics based means its messy and effectuations are chaotic)
It’s very do-able on Roblox, just don’t do it at 50 hz (roblox servers can go up to 60hz but they often fail to, hovering around 50 to 55). I’d do it at 30 to 40hz for consistency, anything lower you’d expect some lag.
Whats important is not to just have clients send CFrame. Rather, you send CFrame and velocity. To stay on the example of rocket league, when two cars hit the ball at the same time, this happens:
Car 1 says “I hit it first!”, ball hits Car 2 and bounces over! (due to ping, it thinks it was first)
Car 2 says “I hit it first!”, ball hits Car 1 and bounces over! (due to ping, it thinks it was first)
Server (realizing this was instantaneous, especially because the 30hz compiles actions into discreete units, meaning it was literally the same time to the server POV): “The velocity cancels out from both cars and then the exit angle is divided amongst them.”
Clients now see the ball shoot out to the side of least resistance between the two (which is what happens IRL, like pinching it out)
You could also do this without needing any angle division (in fact Rocket League may be skipping that) but it really depends on your testing and the game.
edit: some confusion, yes this would be server authoritarian and you could simulate it in roblox by having a ‘server ball’ that clients replicate with their own client ball, which may be easier for roblox given the ability to math accurate physics in a low-level programming setting is limited.
Ah okay, So I’m assuming based off what you are saying that you are implying that I should still use a client sided hit detection right? I’m just worried because if I use that then higher MS players will be at a severe disadvantage compared to just doing hit detection on the server where ‘everyone will be at a disadvantage’ making it a little more fair somehow.
The main reason I’m doing all of this research into networking and solutions for my game is due to how unfair it is for high MS players because even though if they touch the ball first, the low MS player (that touched it slightly later in time) will always be the first to send over the actual event and just the unfairness in general so I’m looking on how to make it a smoother gameplay for everyone.
This is done by confirming the hit on the client and then listening for confirmation from the server, instead of waiting for the server response and then doing the action. In-case of a rejected response the client response gets completely canceled, which would look like the ball teleporting back in sync with the server.
Thank you so much for your response I was just looking into this kind of stuff and I came across your blog. Doing it like that sounds interesting though, because if I understand your message right: when you’re yielding for the server it’s obviously gonna cause some noticable delay and lead to a lack of responsiveness which is what I wouldn’t want. Are you just doing this via a RemoteFunction?
Networking will always have delay. The server has to decide what happens, which is why you handle change, not the actual state of the ball in this case. That’s why in his example, he’s verifying changes to the ball (a client hit it) not where the ball is every single frame.
Also, in your other reply you mention advantages but the reality of the matter is you can do as much lag compensation as possible (lag compensation = client prediction most of the time), but you’re not going to get around the fact people with higher ping are going to have a worse time. You should do what you can by utilizing what he said above and such and the rest of the weight to carry should be prevenative measures to ensure clients from different regions do not pair up against each other. Check into here. How to get a Server Location/Region on Roblox