NPC Serialization Problems

Hello, I'm having a strange issue serializing NPCs in my game. For some reason, whenever I network instantiate even one NPC (controlled by the master client) and start serializing the position and rotation (among other things) of the master client and NPC, any client that then joins slowly receives those updates with a massive latency of over 40 seconds. RPCs, however, still seem to get sent through properly which is quite strange.

I can't imagine that it would be my game logic as the NPCs work fine under the Unity networking implementation. Also, servers hosted with only the master client in it (no NPCs) work perfectly. The serialization send rate is set to 11. Is there something basic that I could be doing wrong here?

Comments

  • Please verify the server ping(PhotonNetwork.GetPing()).
    It could be that the ping is 40ms itself, then you'r messages can of course never arrive faster then that value.

    The cloud uses several locations, so sometimes my own ping is as low as 9ms (Amsterdam-Amsterdam) or as high as 40ms (Amsterdam -> USA). ExitGames will be implementing some localisation improvements, so that you'll connect to the closest server per default.


    EDIT: Ooh OVER 40 seconds? Well that's messed up indeed.

    Are you using a lot of observing PhotonViews?(lots of NPCs?). I'm suspecting that the behavior will be fine if you use only max 5 -10 observed photonviews and over that it starts causing trouble.
    Could you please verify this? Then I know what we'd need to fix.
  • Leepo wrote:
    Are you using a lot of observing PhotonViews?(lots of NPCs?). I'm suspecting that the behavior will be fine if you use only max 5 -10 observed photonviews and over that it starts causing trouble.
    Could you please verify this? Then I know what we'd need to fix.

    Each player/NPC has 5 PhotonViews observing attached scripts. All scripts only serialize an int value except for the position sync which serializes a Vector3 and Quaternion. The max number of NPCs in a server at a time is 3 - though Photon is having issues even with 1 NPC and the master client.
  • Hm, so when you test this, you have at least 2 players + 3 NPC = 5 * 3 = 15 photonviews. This really shouldn't be a problem, but possibly relates.

    Could you check the following?

    - Have you changed 'sendRate' and/or 'sendRateOnSerialize' ?(the default rates should be OK: 20 and 10)
    - How is the delay in receiving player updates between the 2 players? (And does disabling the NPCs help?)
  • Leepo wrote:
    - Have you changed 'sendRate' and/or 'sendRateOnSerialize' ?(the default rates should be OK: 20 and 10)
    - How is the delay in receiving player updates between the 2 players? (And does disabling the NPCs help?)

    Both the send rate and serialization send rate is set to 11. The updates between the two players is the same as the NPCs; the sync is roughly 30-40 seconds behind the current position with each update coming every few seconds or so. The only thing that works seems to be hosting a server without NPCs or hosting in an NPC server with the network instantiations disabled for the NPCs.
  • I think that somehow the network messages are beginning to pile up on either the sender and/or receiver side.
    Please set the sendRate and sendRateOnSerialize to their defaults and see if that helps (or simply not changing them in your code). Possibly sendRate needs to be X higher then sendRateOnSerialize to cope with the messages.
  • Leepo wrote:
    I think that somehow the network messages are beginning to pile up on either the sender and/or receiver side.
    Please set the sendRate and sendRateOnSerialize to their defaults and see if that helps (or simply not changing them in your code). Possibly sendRate needs to be X higher then sendRateOnSerialize to cope with the messages.

    Having the default values for both send rates doesn't seem to do anything unfortunately.
  • If you are able to send us a (stripped down?) repro project that would really help us to track down the problem. Otherwise, we'll try to find a similar situation ourselves ( 2 players, 3 "NPCs" - 5 photonviews per character..it must be something related to PhotonView-observed load)