Cars Predictive Pathing

We can’t create a system like this ourselves, Roblox doesn’t give us the required access/apis to the engine.

We can, but it probably won’t look quite right;

RunService.Heartbeat:Connect(function()
    for _, Car in workspace.Cars:GetChildren() do
        if Car.NewPosition.Value ~= Car.PrimaryPart.Position then
            local PlayerPing = Car.Player.Value:GetNetworkPing() + LocalPlayer:GetNetworkPing()
            Car:PivotTo(Car:GetPivot() + (Car.PrimaryPart.AssemblyLinearVelocity * PlayerPing))
            Car.NewPosition = Car.PrimaryPart.Position
        end
    end
end)

(basically pseudocode, I know it won’t work because :GetNetworkPing doesn’t function for other clients - only local player, but if you set everything up then what was described should happen, players should be moved forward by their velocity and ping to be more representative of where they are on their screen).

1 Like

That’s unfortunate, racing games especially need something like this because I’ve just created race positions for my game. I calculate them on the server because if it was calculated on the client people would be confused when it says their first but they finish in second or third. But because it’s calculated on the server, it could be telling them they’re in second when it looks like they’re in first, I’ll try creating my own system but I’m not really good with this kind of stuff. (physics)

Also, @Judgy_Oreo I looked at your code for an example of how to do it and I found this post which lets you see everyone’s pings from the server. I was wondering if I’d need to change anything else or if it would pretty much work with just changing the bit where you check people’s pings?

Edit: I just realised that we need to see others players’ pings from every client separately, I could send everyone’s pings through a remote event though…

Hey there, another developer here struggling with the same issue on collisions in racing games. The way it is now, it is impossible to create a realistic car racing game on Roblox. Collisions without vision lag is necessary to provide an immersive experience.

1 Like

I wonder if this was a problem pre-PGS… Probably.
It’s interesting that this has not been addressed yet in the physics system. Currently, the only solution is to set the network ownership to the server, but input lag will make the gameplay horrible.

Well I don’t see why you can’t account for each of the player’s ping now that workspace:GetServerTimeNow is available. :
Meaning you would have to move the players who are a bit behind the certain intervals accounting how far the difference is between their time and server’s time.

At this point, it’s down to the developer to develop some form of system to “fix” this. That said, it’s an uphill battle.

You’d be better off supporting my other thread, here. Staff responded pointing out that UDP is already how the physics are ran, so forget that part, but there is still currently no good way to get ping in real time to propogate to the clients & make adjustments to where cars should be.

You’re on a right track & I took a stab at it using your code idea with some extra additives to make your psuedocode into proper code.

When reviewing the footage, I measured the difference between me reaching the line and them reaching the line, I got about 6 frames [60 fps]. That’s about .1 of a second but the margin of victory was recorded at about 1/3 of that.

So still not perfect, but it’s closer one could suppose. My thing is, I’m still just not so certain one can get a reliable enough ping of all players, to be readable locally, to output accurate results.

4 Likes

Reviving this topic here…
i dont know how but the guys at Avenue Vance Empire claim that they successfully solved this issue and could do real time collision physics on A-Chassis, no lag at all on their pre release ION Apex Racing, i wanted to know how they did that and if its really true, because the beta game costs 500 robux and i dont have the money to buy the game to test

1 Like

I’ve seen it in the videos and I can hazard a guess at how it’s done but it still has some drawbacks considering this isn’t actually great ways to obtain ping still. (GetPing is still not a perfect function for this use case)

2 Likes