Search Unity

Multiplayer engine for a game with physics

Discussion in 'Multiplayer' started by magister_yoda_, Mar 22, 2021.

  1. magister_yoda_

    magister_yoda_

    Joined:
    Mar 27, 2016
    Posts:
    32
    Hi everyone. I have some questions about multiplayer in unity, hope you can help me.
    We are planning to create a game like Head Ball https://play.google.com/store/apps/details?id=com.masomo.headball2&hl=ru&gl=US.
    I mean realtime multiplayer where two player will play against each other kicking the ball. This is our first multiplayer so I have several question to understand the best way to create this game.
    1. What multiplayer engine should I use for such type of games? I tried to used Photon. I successfully synced two players but syncing the ball has appeared a problem. The ball shows weird behaviour when I hit it with the non-master player. And there is a lot of lags.
    2. Can I create this game with physics on Photon or should I search for some other solution?
    3. If not Photon what other engines? How about GameSparks?
    4. Whether I understand correctly that it very hard or even impossible to write a multiplayer game with physics in Peer-to-peer concept?
    5. How would you create this game? What technologies and concepts would you use?
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    I'd expect to have to do a lot of experimentation with the physics for a game like this. As far as I'm aware, there's no out of the box synced physics solution that works great for all physics applications. What approach you'd use would depend on things like the speed of the ball, the speed of the players, how much control over the simulation do you want to entrust to the client, etc.

    You might consider only using the physics system to detect collisions, and writing your own ball movement and syncing system to handle this.
     
  3. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    168
    Don't scare people with such clever words ok?

    It is very easy to synchronize the physics between the client and the server, for this you need to simulate it a fixed number of times per second for both sides. Unity has the necessary functionality for this, and besides, the physics in unity is quite deterministic (the result will be predictable)

    After the simulation on the server side (host), send the result of the simulation to the client, and the client in turn simulates the physics in the same way as the server creating the illusion for the client that the game goes on without delay, at the time of receiving the result about physical objects, we simply adjust the objects that are located in the wrong place...
     
    Last edited: Mar 23, 2021
    Joe-Censored likes this.