Answer the question
In order to leave comments, you need to log in
Vehicle sync in game?
Hello. I'm writing a multiplayer (C++) and wanted to get some advice on how best to synchronize cars between clients , not counting the physics on the server .
The following functions are available to me on the client :
Create car
Set position
Find position
So... Each of the players can push the car, thereby changing its location. Of course, if two players are in each other's streaming zone, then the bots on opposite clients will push the car in the same way and therefore everything is fine. What if one player leaves the streaming zone? Then it turns out that the second client will push the car, and the server will think that the car is standing still and the second player, when he enters the streaming zone, will spawn the car exactly in the place where it was originally. It turns out to be out of sync. And what to do? Take the position of the car from the client who is pushing the car? And how do I know that it is he who is pushing the car? Maybe with that client there are still 10 players in the streaming zone. Which of these 10 players will receive a new car position from the client? You also need to take into account that the player can use the cheat and teleport the car to no one knows where. And if you collect the position of the car from all the players in the stream zone, but it does not match for one? Even if you make a check that someone from one of the car positions does not match, ban him, then what if all 10 players agree and teleport the car somewhere? And how to make position synchronization? The same problem with the HP of the car. what if all 10 players conspire and teleport the car somewhere? And how to make position synchronization? The same problem with the HP of the car. what if all 10 players conspire and teleport the car somewhere? And how to make position synchronization? The same problem with the HP of the car.
Answer the question
In order to leave comments, you need to log in
and the server will thinkthe server doesn't need to think, it needs to know. The client has moved the car - must inform the server. Moreover, the server must also check what was moved where. What if they are cheaters, they want to move the car through the wall, or they move too fast, or even decide to move the neighboring brewery instead of the car.
Can be done through checking the physics of nearby cars by the client himself.
And if there is a deviation (cheat) - report to the server.
If such a message comes from several clients at once regarding one of them, this indicates a possible cheat and you need to additionally check this on the server to most accurately confirm the fact of deception.
However, in the absence of nearby cars, you need to control the speed of movement (the length of the displacement vector and time, and other parameters) exclusively on the server.
spawn the car exactly in the place where it was originallywell, you need a timeout for which the object is removed from the game world.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question