I'm working on a multiplayer game right now and I want to have 2 players that have 60 seconds to build themselves a machine to fight against each other.
These "machines" are made out of hundreds of lines that the players can create. I already made everything work as a singleplayer game, but now I want to sync these lines. I think it would be a waste of bandwidth to sync every single line. What is the best way to sync hundreds of objects that are pinned to a core which the player can move?
Any help is appreciated
Have you tried it? Bandwidth is generally more of a concern as you add number of players as the amount of data sent is exponential per peer. 1v1 you should have a pretty large amount of room to work with.
Develop games in your browser. Powerful, performant & highly capable.
I would send an array containing the origin and finish of each lines (or various modules those lines are meant to link together) and have it being "built" as well on each peer side on start of the session.
Once the overall structure is built, the fact that they are pinned will move them automatically on all peers equally when you move the core (since in the end they are pinned to it and all depends on the core, the angle, position, etc...).
Thanks for your help! I just created a program that will put the building of each player in an array and load it again later from the json string. It works perfectly!
But how should I send the array to the other player? Should I do it with the broadcast action? Because the array is quite large.
You need all peers to have those data, so yes, I would broadcast the informations and prevent play/session start as long as the informations haven't been completely broadcasted.