Maintaining player position consistency

I have a game where 2 people are running with each other (they have different speeds and it is constantly changing) and they must keep the difference in their positions less than 30 studs. If the difference of positions is >= 30 studs they both die. The problem is that, due to latency/delay in network replication between server and client, the players (say A and B) and the server will all have a different position difference.

I have a meter on the clients displaying the difference of position so they can keep this in check.

I have issues regarding both methods to display it:

  1. If I send the distance between the two players from the server every 0.1 seconds to the two clients, their character positions are out of sync with the server distance. So they have to keep looking at the distance meter only, and ignore the actual positions of their characters, which might be confusing.
  • I also tried sending the player position from the server to the client but it causes a jittering effect (other player moving to the server position but instantly going right back)? I assume it’s because of network ownership of the characters that it’s basically overriding it? I’m not sure
  1. If I just have the distance meter between the two players measured on the client. Then I could have, again >=30 studs of difference on player A. But player B could have, say, 20 studs of difference on their side. If the server kills them both and you tell player B that the difference of distance was not kept in check, they will be very confused (because on their side they were doing good). And you cannot really communicate properly to keep this distance down unlike in option 1.

I’m not really sure what to do here.

Bumping this post, if it’s impossible or unfeasible then just say that. Or if there is somehow an alternative method? Maybe instead of displaying the exact distance we do something else?

I think i’ve seen a post about something similar to this solution. Perhaps theres a way to prevent the server from moving it normally?

turns out you can’t disable it, but this post seems to explain a way that might work:

Maybe try sending their positions from server to client in a Heartbeat loop using UnreliableRemoteEvent

I think problem 2 could be solved if player A is >= 30 studs it sends a message to the server and the server checks if player B is >= 30 studs from player A in the last 2 seconds for example.
If the client detects that the distance is too much then make the meter go red and the server gets notified. If the server finds that >= 30 studs is not true it sends a message back to the player and the meter goes normal again.
If it’s true on the server that >= 30 studs then kill them.
Automatically if a player dies their meter should be reseted to be normal on the client.

But won’t that not solve OP’s problem of the player dying when it seems they shouldn’t die?

Well if the player B and player A had >= 30 studs locally than both the players had send a message to the server than the server can kill them without confusion for both players.

oh wait nvm
I got confused over the whole “server check client check” thing lol

ok but wouldn’t that mean that say the client is 30+ studs away, but the server isn’t, I won’t die?

Here the server just acts as a bridge for data communication and here both the players had 30 >= studs and the server gets notified and checks if both had send a message in a range of 3 seconds for example. The server is not the truthteller of their positions in this scenario but the clients are.

1 Like