Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Networked flock of birds, do-able?

Discussion in 'Multiplayer' started by bigkahuna, Feb 21, 2009.

  1. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    I'd like to have a group of flocked birds on the server appear in a client player. I haven't tried this before because I was concerned that the bandwidth of 25+ independently moving objects would be too much for my simple 2 player game (connected via a LAN). Any thoughts or suggestions?
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    you could make the flock a particle system and just syncronize the particle emitter position instead of the positions of the distinct birds.

    if it is no particle system, then you would have to find a similar thing that defines their flock position and direction and potentially a few other datas that allow to reproduce a similar behavior on the clients (that data only would need to be sent at init).
     
  3. ProtonOne

    ProtonOne

    Joined:
    Mar 8, 2008
    Posts:
    406
    +1 on this idea.

    In InvinciCar I have about 100 NPC cars driving around the 2 player game. But they are following a random, but defined pattern. So all I need to sync is the animation time of the pattern once at the start of the round and the will follow the same track on both clients.

    When a car is hit (or in your case, when a bird is shot), then a RPC is sent to both flocks saying a specific bird should not follow the pattern, and let physics take over and let it drop from the sky. I don't sync them at this point, so they could land in different places, but you could add that ability if it is important.
     
  4. Der Dude

    Der Dude

    Joined:
    Aug 7, 2006
    Posts:
    213
    You're worried about bandwidth in a LAN?

    Lets do a little math here:

    25 birds means 25*25 updates per seconds (though fewer would suffice as well).
    Each update includes: position (Vector with 3 floats), rotation (Quaternion with 4 floats) and a timestamp (double; counts as 2 floats). So 9 floats per update. Each float consists of 4 bytes. So thats 9*4 = 36 bytes per update.

    Per second you would send 25*25*36 bytes. Thats 22500 bytes per second. Lets kick it up to 24000 bytes for all the internal stuff Unity might add. Thats 24 kb/s. What can your LAN handle? Around 100 MB/s? So don't worry about bandwidth, when you know you're going to be in a LAN.

    I would always recommend more bandwidth usage over error-prone and partly costly optimizations when operating in a LAN.

    Would love to hear about your experience with this though.
     
  5. kroll

    kroll

    Joined:
    Jun 11, 2007
    Posts:
    17
    +1 on that. Bandwidth is not the issue. latency might be. How precisely do you need the flock to be updated ? Is it acceptable to have the flock in similar place, but individuals wrongly placed ?
     
  6. Teut

    Teut

    Joined:
    Feb 24, 2009
    Posts:
    2
    It depends if the flock of birds are relevant to gameplay and then if the exact position is relevnt at any given time.

    As mentioned previously you normally sync clocks and let them fly on all clients dependend on the clock in a fixed pattern (even when random stuff influences their pathing you can get that "fixed").

    In World of Warcraft they do this even with monsters. They are client run until the player "tags" them and they become an active synced object. At that point they go to their server position (if different) and are server controlled.