- Home /
looking for an idea about syncing (timing) a multiplayer game
I'm designing a multiplayer game that have a bounce ball.
instead of having a ball and use OnSerializeNetworkView to sync it's position (because it's laggy sometimes) i want to create 2 balls in 2 sides (one ball in player1 field and one ball in player2 field).ball move is deterministic so i need to check it's position every some seconds to make sure players are not cheating and the ball is moving correctly ...
how can i do this? where to start ? i think i can send the position of ball by RPC calls every 1 sec but when the rpc call send from player1 to player2 , player2 will receive it a little later and can't check ...
I would like to express that this is more of a forum topic.
If this will be a air hockey or pong game, this is nearly impossible.(I have tried in the past) Achievable, but not fun to play.
The best result I could do was, sending information of player object and ball position to other player, only when player object touches the ball. both sides do their own calculations of physics, velocity etc... also you may send information of target points of players to each other.
several methods can be used for that, you should $$anonymous$$imize the data to be sent and received. an example would be sending a header and $$anonymous$$imal information. if you transmit player position, you may do something like this;
lets say player position is a vector of 5.431231, 7.456412,0.
byte[] playerPosition = new byte[5]; playerPosition[0] = (byte)'A'; //header to recognize what information is received. playerPosition[1] = (byte)54; playerPosition[2] = (byte)31; playerPosition[3] = (byte)74; playerPosition[4] = (byte)56;
then in the receiver side, you should be decoding the data received.
I'm not sure how Unity networking works, would not want to give any false information, someone else can help better.
I don't know, if something better can be achieved with current tech, I have not seen a good one tough. And also this is the reason why you mostly see multiplayet in turn based games, and games that latency can be neglected and does not affect gameplay much.
hmmmm tnx . good idea ... i can check position after collisions.
Your answer
