Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    Dismiss Notice

Behaviour of OnSerializeNetworkView

Discussion in 'Multiplayer' started by Der Dude, May 25, 2008.

  1. Der Dude

    Der Dude

    Aug 7, 2006

    I have mentioned before, that we use our own UDP layer. However to avoid having to mess with NAT Punchthrough, we are trying to convert to Unities Networking to keep our bases covered.

    I've run into a little problem. In our game, there are a lot of shots being fired. Thus it is not necessary for every shot to reach every player. Ergo we use Unreliable State Synchronization.

    These shots are stored in Wrappers called "ShotData". When fired, they are put in an ArrayList. These ShotDatas are then serialized in OnSerializeNetworkView. Afterwards the list is cleared. Now it came to my attention, that the shots of any player only ever reach one other player.

    There are no error messages. All NetworkViews are set up correctly.

    Code (csharp):
    1. //// Serialize Shots
    2. amount = outShots.Count;
    3. stream.Serialize( ref amount );
    5. for( int i = 0; i < amount; i ++ )
    6. {
    7.     currentShot = (ShotData) outShots[i];
    8.     currentShot.Serialize( ref stream );
    9. }
    11. outShots.Clear();
    12. //
    Is OnSerializeNetworkView called for every connected player? Ìf yes, how do I find out to which player I'm sending at the moment?
  2. Der Dude

    Der Dude

    Aug 7, 2006
    I wonder if my problem hasn't become clear through my description. Please ask if you don't understand something.

    As of now I simply use RPC Calls for sending shots over the network. It just seems unnecessary to use reliable transfer for something that doesn't need to be.
  3. Schaerer


    Dec 17, 2007
    We are having the same problem. Everything goes across the network except the bullets. We can see the bullets server to client, but not client to client

    They only thing we can think of is that we are setting the fire variable from outside the script with the OnSerializeNetworkView!!! or that since fire is not a game object then it does not work!!!

    We will try RPC calls or making fire a game object.