Possible ways to use predictive positioning to bypass server delays

So on Roblox, if you try to place things at the player’s torso position, but that player is moving, the object will be placed where that player was, not where that player is. In my game, I use magnitude checks to act as “hitboxes”. If you are within a certain distance from a point relative to the humanoidrootpart’s cframe, you are considered to be “hit”. This system works to an extent, but becomes completely inaccurate the minute a player’s movement is factored in. I realize there isn’t much you can do to fix this without using the client to handle hitboxes (which is an awful idea), but I’m wondering if anyone has any ideas about how to make up for this problem and place the hitboxes where they SHOULD be. Only thing I’ve tried so far was offsetting the hitbox positioning a bit based on the player’s velocity, but I’m curious to know if there’s a better way. Maybe something involving .Touched?

Can you describe your problem at a higher level? What is this hitbox prediction system going to be for?

Red cube = where the server thinks the player is
Green cube = predicted position of the player

I tried writing a system like this before, and would not recommend going through with it. There’s too much network overhead and there’s a lot of volatility when you get into higher velocities.

If you still want to go through with it, I’ll send you some code snippets.

1 Like

The system is for a fighting game. There isn’t too much super speedy movement, but the issue is noticeable enough to where if you’re chasing someone, you can see your attack go right through their body, but the hitbox will be behind you so it won’t hit them.

Did you ever find a different solution to this problem then? If so, I’d love to hear about a different methond.

Well, client movement is client-authoritative anyways soooo maybe it doesn’t matter so much if the detection was on the client with some basic sanity checks on the server (“are you within like 20 studs of that player you said you hit?”)

Normally I wouldn’t suggest something like that, but really ROBLOX doesn’t give you that much control over the networking stack so you’re going to have a pretty rough time implementing lag compensation.

My system involved getting the ping of all clients at a given interval and doing some math based on the velocity of their HumanoidRootPart. I’m pretty sure there are better ways to do this but then again, this did work out for me at the expense of network performance.

i would love to see some of the code snippets if you still have access to them