This question already has an answer here:
I am implementing the multiplayer(client-server architecture) of a game, and I came to doubt about entities common to players.
I understand how to share information such as the position of the players among themselves. However I am caught up in the logic of how to do for the common entities between them.
Imagine: Two players and a chicken, how would you share the position of the chicken between them? because it needs to move, and can not move in different places in the two clients, the two clients should see the chicken in the local place, but if I send the position of the chicken of one client, and also the other, there may be conflicts.
What should I do. Choose one of the clients to be the "master" who will send the chicken position to the other players? How do they handle this in online games?
I am thinking of doing the following:
I can not imagine the calculations being done on the server working properly, I will use the example of the hens, my hens would have an AI maybe too complex to stay on the server. I thought the following, one of the clients of the update area, as it is a big map, the clients are receiving updates being in chunks of the map, then one of the clients would be the master (the first one that entered the channel) , the others would just listen to it, the "master" client would then send to the server the chicken positions/states and the server would send to all the clients enrolled in the channel the chicken position/status.
It works similar to a "token" who is at the top of the channel users list is going to deal with the chicken's calculations.
advantages: - Less work for the server to handle.
Disadvantages: - Poorly trained players could change the position of the hen and make the game experience unpleasant.
What could you do to avoid this disadvantage?