Search Unity

Are physics feasible in a non-authoritative server infrastructure?

Discussion in 'Multiplayer' started by iEchoic, Apr 16, 2014.

  1. iEchoic

    iEchoic

    Joined:
    Dec 27, 2013
    Posts:
    14
    Hi all,

    I have a game that has a somewhat-heavy reliance on a physics engine for actual gameplay mechanics (let's say it's like a 2-4 player Angry Birds, where there are physics structures that can be toppled), with potentially 20-50 physics objects on the field at a given time. I was planning on using Photon Unity Networking cloud service with Unity's built-in 2D physics engine.

    I've read through the Unity high-level networking doc:
    networking high-level overview. My question relates to the distinction between authoritative server and non-authoritative server as referred to in this doc. In particular, note the following:

    My question is: is it feasible to implement a physics-heavy game via non-authoritative networking? Has anyone done it? My sample algorithm would be something like so:

    1. Pick one "authoritative player" (a "physics host") out of the players in the game. The "authoritative player" is authoritative with respect to the state of physics objects in the game, for the duration of the game.
    2. The "authoritative player", each interval of time (let's say 1 second - a small enough interval of time to prevent the non-determinism of the physics engine from causing significant divergence) broadcasts the state (position, rotation, forces - all properties required to mirror the state exactly) of all non-sleeping physics objects to all other players in the room.
    3. The players, upon receiving state information for the physics objects in the game, update their physics objects to keep them in sync.
    4. With regards to player actions, there is no authoritative player - players simply broadcast their character information as in any other non-authoritative model.

    Does anyone see significant issue with my approach above? Does anyone have a better approach?

    Thanks!