Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Networking and physics - where is the limit?

Discussion in 'Multiplayer' started by Thomas-Lund, Mar 14, 2008.

  1. Thomas-Lund

    Thomas-Lund

    Joined:
    Jan 18, 2008
    Posts:
    465
    Semi cryptic subject, but the background for my question is based on trying to make a flight sim using Torque.

    We got it pretty far using a propriatory closed source physics API, but stranded on the physics drifting on server and client side without us having a chance to fix it - make the game unplayable after a while.

    Check out some really old screenshots here: http://www.airaceonline.com/screenshots.aspx

    WW2 online airplane dogfighting basically.

    Now I'm wondering if a port of this would be possible using Unity using the build in physics.

    What I'm especially asking is what mechanisms Unity has to sync physics, what potential pitfalls I would fall into, and if I even need to worry.

    Are there some limits to using heavy physics over the network with maybe 40-50 simultaneous players in the air?

    Thanks

    /Thomas
     
  2. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    Hi Thomas,

    physics and networking sure is not a trivial thing to implement but I'm sure it can work in Unity. AFAIK, there's even some networked racing demo out there, which I think is probably even harder concerning the physics/networking issue than a flightsim (correct me, if I'm wrong). 40-50 people is quite a few, though ;-)

    Have you checked out:
    http://unity3d.com/support/documentation/Components/net-StateSynchronization.html
    ?

    There it says that Unity supports Rigidbody-synchronization. I haven't worked with this myself, though, so I don't about any pitfalls you might run into...

    Sunny regards,
    Jashan
     
  3. Thomas-Lund

    Thomas-Lund

    Joined:
    Jan 18, 2008
    Posts:
    465
    Thanks for the reply.

    Havent looked to deep into it yet, as I'm still very very careful spending to much time on this.

    Working on other games that are much smaller in scope, and had silently already discarded Air Ace to ever be finished. Now after using Unity for the first time (game announcement soon) I've started to become interested if it would be possible here instead.

    40-50 is definitely pushing it I know - but wanted to provoke some response of the "border" of Unity capabilities :)
     
  4. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    Well, the "border" of Unity definitely depends very much on your game design. I'm currently trying to create a server that will handle a couple of hundred users (will need a lot of people to test that, some day soon). I'm not using physics simulation, however, and try to create the game logic in a way that supports this large amount of users by being very predictable in almost all cases.

    Just as a little note on one "terrible mistake" I made here in the game-design: I had this idea of "bullet-time", which is basically just a slow-motion power up that a user can use when he's in a difficult situation (it's a game based on the Lightcycle / Tron-style "genre" ;-) ). In single player mode, it's trivial: You just set Time.scale to 0.2 or something, and there you have it. Getting this multiplayer was a little bit trickier because when the time-scale changes, you can easily mess up your synchronization stuff. But it was still comparatively easy (of course, bullet-time means that all players get the slow-mo effect, which is part of the fun of it ;-) - for some it may be beneficial, others get to practice patience for 10 or so seconds).

    Now, however, I need multiple game sessions running on the same server independently (I can only have 20 people in a single game session). Now guess what happens if someone goes to bullet-time on a server with 10 sessions and all those sessions slow down. Imagine one person kicking off "bullet-time" in every session and you'll have "Slow-Mo-Tron" almost all the time ;-)

    Might be a rather "esoteric feature", but it's one of my favorites, so I'll try to find a way to get through without having to cut it (obviously, I'll have to let the Time.scale alone on the server)... we'll see how it turns out... ;-)


    With the flight sim, I guess one thing that might get very tricky is having a lot of bullets flying around and simulating and synchronizing each and every single one of those individually. If you have 50 users and each one shooting 100 bullets per minute (because they're all in aggro-mode and want to see how much your server can take ;-) ), that means 50.000 objects to be handled in one minute, many of them concurrently (which, of course, depends extremely on one bullet's lifetime). And worse: It might mean 50.000 x 50 (players) x (time / messages per time, something) messages being sent out...

    If, on the other hand, you let the bullets be simulated only on the server and do the bullets on the clients "individually", that should not be an issue at all. Bullets should be trivial to predict, if you don't simulate gravity for them because they're too fast for gravity to have a significant effect. With the latter "design", you still have those 50.000 objects flying around on clients and servers, but the server only sends one single message per bullet hit to the 50 clients.

    And: When you limit the ammunition, people will think twice before going crazy in aggro-mode... they might be able to put your server to a limit for a moment, but then they'll have run out of ammo ;-)

    Sunny regards,
    Jashan
     
  5. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    Hey Jashan

    Going a bit off topic here by addressing your game design problem. I had a session with some friends of mine about a year ago where we among other things discussed the issue of bullet-time in multi-player.

    The best idea we came up with was area-specific bullet time. Basically the player who initiates bullet-time creates a sphere around him or her where bullet-time is active within - the outside of the sphere being unaffected.

    This means a player can initiate bullet time effective for himself and perhaps his group without annoying the other players on the servers.
     
  6. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    To be continued...

    at: Bullet-Time in Multiplayer...

    ;-)

    I'm now officially a member of the "keep the threads clean and do not tolerate hijacking anymore"-initiative ;-)