Hi! The moment has come, I want to make multiplayer on Unity by using P2P connection. For example, I'm making FPS game. How to realize synchronization different actions of player(hitting something, drop loot)? I have two ways:
I will make Dictionary<id, gameobject> of all entities, which I will synchronize. When a player1 hits something, he will send ID of this entity and his own damage, then player2 will get gameobject by id and component, which has property hp, and will subtract damage from hp;
Player1 will send his own position, Vector3 from center of screen and length and damage every time, when he will press LMB. Player2 receives this information and makes different calculations with Raycasts.
What is better? Can you give me advice about synchronization of gameobjects through p2p?
P.S Max number of players is 4;
P.P.S. Sorry for my bad English. You also write title of the best English grammar book.
Is there any reason you want to do it peer to peer?
Should I use client-server model instead p2p? I don't know can server support several game rooms.
I think client-server is the generally accepted way of doing this kind of thing - it probably has the least amount of problems.
What do you mean can the server support multiple game rooms?
I'm guessing you're asking if your physical server can support multiple game servers? That depends completely on the hardware in the server and the requirements of the game server.
If you have a game where cheating does not matter and it doesn't matter if someone gets an unfair advantage if they try: go for peer to peer where each client is their own authority and tells other clients what happened
If you need the players to play fairly and not give themselves an advantage by cheating: go for the client-server where the server is the authority and checks requests from clients before letting them pass or rejecting them
I mean that player1 create game room and his friends connect to him and player2 create game room and his friends connect to him; Can they do it with one physical server?
I haven't used Unity to know if it's technically possible but as Walter said above, with sufficient hardware etc a physical server should be able to host multiple game servers.
Sorry, you need to Log In to post a reply to this thread.