Search Unity

Physics and Laaaaggg

Discussion in 'Multiplayer' started by hypnoslave, Nov 21, 2009.

  1. hypnoslave

    hypnoslave

    Joined:
    Sep 8, 2009
    Posts:
    439
    i'm sure this has been brought up before a few times.

    I'm mucking about with a small little zero g networked game, i'd like to have a bunch of physics debris floating around.

    as far as i can tell, i've got to use an authoritative server for anything physics related for a few reasons, but of course having more than a few physics objects in the scene is causing unity to lag like crazy... i'm assuming because i'm asking the server to calculate and return transforms on 30 objects every frame.

    Anyone out there have any bright ideas for implementing physics in a networked game? it's beginning to look very un-feasible.
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    There is very little you can do.
    thats why physics were not used as elemental game play aspects in MP up to DX10 where the gpu power reached the required base so they can be calculated in a numerically stable and safer environment (-> through shaders).

    Crysis is about the best example for that as physics only exist if you play the MP with Vista and DX10. The DX9 game and its servers have no physics.
     
  3. hypnoslave

    hypnoslave

    Joined:
    Sep 8, 2009
    Posts:
    439
    interesting. thanks a lot.

    well, S***. it certainly seems like physics are a must for most games, at least to the extent of calculating player collisions and stuff like that. I hope it can handle physics on 20 players connected to a server + projectiles...

    ??
     
  4. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    you can do that but you wouldn't sync the data forward and backward.

    let the client run its simulation, let the server run its simulation and verify result if they are reasonable on the server (they will likely never be equal due to calculation unprecision)
     
  5. duke

    duke

    Joined:
    Jan 10, 2007
    Posts:
    763
    Yeah just do a verification like dreamora said. Run it both on the client and server, and if the results are within a threshold, no correction is necessary. You will, however, want to have the server correct any resting position.

    In a mod I was working on, you could resuscitate players, but because we had ragdolls, if you got popped in the head it was a clientside calculation and so you're final body position would be different on every client. Because this was important (if it's not, you don't need to correct it), the final position of the body was corrected and uniform across all clients so that it was in the same spot.
     
  6. magwo

    magwo

    Joined:
    May 20, 2009
    Posts:
    402
    What?? What does rigidbody physics have to do with DX9, DX10 and Vista? Nothing. Rigidbody physics is still done on the CPU.. shaders are only used for "effect physics", which is irrelevant to gameplay and not synchronized over network.

    Networked physics gameplay is entirely feasible, you just need a lot of tricks and smart designs. And you need to accept that it's never going to be perfect and without glitches. What you need is "good enough to support the gameplay".

    There are tons of games out there that have excellent physics-heavy gameplay and support ~64+ players.

    Not true. If Unity has problems simulating 30 rigidbodies, you're doing something very strange.

    However, the network data required to synchronize these objects should be around 80 K/s for each client connected. This is where the "smart designs" come in. Proximity-based variable update frequency, scheduling, error allowance etc. Like I said, it doesn't need to be perfect.. it needs to be good enough to keep the gameplay fun.