UDP & Ping Detection for sake of Predictive Pathing

Predictive Pathing Tool Kit

As a Roblox developer, it is currently not feasible to do your own predictive pathing to overcome issues with latency between client and server when related to fast moving objects that have a network priority on the client due to player input.

If Roblox is able to address this issue, it would change the world of Racing games on Roblox, by allowing developers (like Myself) to finally cinch tight the problems involved with “Vision Lag.”


The Problem

A brief on “Vision Lag.” Each client may see themselves as “winning” when the server displays them as side by side. I go into more detail in this 17 minute video.

I know Roblox has no drive to creating a predictive pathing system for us due to the lack of activity on my previous thread and talking to various staff in the past from the physics team. So at the very least we need the basis of tools to handle it ourselves.

While early tests of such a system went well:
ezgif.com-gif-maker (36)

The player floating behind the opponent car would be where the car would normally be placed. The car goes through the wall at the end due to the high impulse of the stopping force. GTA V has this same issue when playing “Chicken” at high speed, but when racing in the same direction, the impulse is low.

Two things are basically deal breakers:

  • No UDP (Unordered packets) Support
  • No Reliable Client Ping Detection

Client Based Ping

When making calculations to place cars in front of where the server currently dictates them to be, you need a reliable source of a player’s ping. Currently the only way to do this is to Fire a Remote event, take down the time you fired it, wait for the response on the server, and then take down the time you received it. Using subtraction, you receive the ping. An officially system provided by Roblox would be less hacky, and likely more reliable with calculating the ping as there are more resources to Roblox in the background to run these calcs quicker. (As well I have worries about firing the remove events too often, as I’d be looking to fire one per frame, per player. That certainly adds up.) In a perfect world, a player’s ping would be an attribute of the player in Game.Players.


### Unordered Packets*
Staff responded pointing out that I was miss interpreting another issue as being TCP protocol, when in actuality it was UDP protocol. Check replies below for their response. Extend this section to see the original posting.

Unordered Packets Original Section

Currently with Roblox’s ordered packets (apart of TCP protocol), when packets get backed up, a car will just dead stop and wait for the missing packet to arrive. Once it arrive, all the packets fire off at once, which shoots the car forward to it’s current destination. What you get is a bunch of garbage as far as positioning data, as seen in races by ION** with lots of cars on track:
ezgif.com-gif-maker (32)

In iRacing, when packets get dis-organized or lost, the car will be “blinked” out. A similar system could be put in place by Developers if UDP was available to them to use, where frames where the packet is lost, the car simply would not be displayed. (To counteract car hitboxes going inside one another, either turning off collisions completely or not allowing cars to collide when a car is blinked back in, already inside another car. The latter is done by iRacing, the former is done by ION.)


* I am by no means an expert on how exactly UDP versus TCP protocols work, and I do understand that UDP is harder to work with than TCP due to it having no error checking (destroying packets that are considered in error), but I do believe that UDP would make this more feasible.
** I do not work for, nor associate with ION Racing, however their live streams show the issues with ordered packets down to a T, making them a perfect example case for UDP Protocols based on my albeit limited knowledge of the subject.
51 Likes

Is the below feature request related/relevant? It’s one that I’ve been looking into as well.

1 Like

I’m not exactly looking for UDP in a sense of RemoteEvents.
I’d be looking for UDP with physics packets. (particularly positional data packets)

6 Likes

Ping: there is work underway to expose ping information on the server. Once it is released you will likely need to do additional work to propagate ping information to clients for localscript use.

Physics/UDP/Unreliable: roblox replication already is based on UDP, and physics data is already sent unreliably. The artifacts you are seeing are not a consequence of the lowest level protocol, they are an artifact of the throttling we have in place that limits physics update rate: when the client doesn’t receive a position update for an object for a long enough period of time, the object will appear remain in place until another update arrives.

There are multiple factors that control how often we send updates. One of the factors is distance to the observer. By default, we replicate physics updates with the assumption that the observer is at the player’s character location, but developers can override this location by setting Player.ReplicationFocus from a server script. Player | Roblox Creator Documentation. This property controls multiple behaviors, with the assumption that this location is the “center” of activity and attention for that player. If you are not using it already, using ReplicationFocus may help your usecase.

Even with ReplicationFocus, there are currently limits for total update data volume, so if you have a large number of physically moving objects, and those objects internally have complex physical structure (non-rigid joints), you may still see artifacts.

14 Likes

Clarifying example: if the player has an avatar over in the stadium, but the game client is temporarily watching the race through a camera positioned far away near the track, setting the ReplicationFocus to be a part near the camera’s position will yield better looking results than leaving the ReplicationFocus unset (defaulting to the avatar, far away from what the client is currently looking at)

7 Likes

This is only true if you move your car/player/object by relying on Roblox physics.
Any other forms of communication (remote events, remote functions and property replication like manually setting the CFrame of an object) will effectivly freeze whenever packetloss occurs until the missing packet arrives.
This behavior can be easily replicated and I outlined this broken behavior here:
https://devforum.roblox.com/t/some-notes-on-the-reasons-for-pingspikes-and-how-roblox-handles-packetloss/1151378

Knowing that in the background Roblox uses an UDP-connection isn’t exactly useful when we are effectivly forced to send our data via an reliable ordered channel anyway with no way to get around that limitation.
This can be seriously bad if you want to to send timing sensitive data between the server and client and this problem is not even limited to custom physics.
For example assuming you are developing a FPS the information that you just shot your gun and killed your enemy may get delayed because an unrelated packet happened to just drop beforehand resulting in you yourself getting killed instead.

16 Likes