AI handling

Hi,

I'm using the minimum indie($9/month) plan with Unity and trying to develop a multiplayer/zombie game. I'm currently having issues with player disconnects and trying to resolve what is causing this and possible solutions. Currently I attach a photon view to each player and zombie. If I don't spawn any zombies, I don't seem to have this disconnect issue, but when I test spawn 20 zombies, I usually get a disconnect within a few minutes. My guess is there is some max limit on the number of photonviews to be handled at a given sendRate that I'm exceeding - I've seen other threads saying at 300 messages per second and default sendRate of 50 per view, this would be 300/50 = 6 views max?

Should I only be using my photonviews for players and not AI/NPC? I could see where players need to send and receive position,etc updates, but AI only needs to send new positions via masterclient? Should I share a single photonview amongst many AI/NPC - any online examples of how this is done?

With photonviews also, should I try limiting messages via modifying my OnPhotonSerializeView to say for example only send AI position updates if the AI is near/within player view?

I've been searching and reading through the forums on keywords like 'sendRate','NPC', etc and through the PUN code as well. In Unity I get the 'QueueIncomingUnreliableWarning' error once or several times before the disconnect occurs. I tried lowering the sendRate to 20 and that resulted in more queue warning messages and raising it to 100 which resulted in less, but all sendRate values seem to have a disconnect after a few minutes for the say 22 photonviews I currently use (2 players + 20 AI/zombie).

Would also be interested in how to modify the PUN code to monitor the message/queue levels to prevent disconnect or further diagnose approaching limits.

Bonus question: Any guesses on how networking(or not) for zombies is handled with games like 'Left 4 Dead'? My guess is the zombies follow certain logic that are reproducible client side, so no sending of AI/zombie positions - just player events with zombie AI recreated on each client with a few intermittent syncs between players where things might be off. This is probably the direction I should go with repeated client-side AI recreation using a single photonview for occasional minor corrections than assigning individual photon views to each AI,NPC,etc

Sorry for the long post and thanks for any help/insight/shared grief,
Jeremy

Comments

  • Many many questions. I can't help in much detail, I fear. But here's some info that hopefully helps:

    The disconnects will happen when you overload the clients with a flash of messages. This can happen, especially when some players spawn a lot of independent objects.

    You can use the PhotonStatsGui script to setup a live overview of how many messages/bytes go in and out. Use the inspector to check which parts of the gui you want to see (it's turned off by default). Then work towards less messages.

    The sendRate and sendRateOnSerialize are two different parts. One set how often the client sends something (if there is anything to send) and sendRateOnSerialize actively calls your scripts to create (!) data and that's sent. Lowering that rate might be an idea but it increases the time between updates.


    On steering the AI:
    In best case, only the MasterClient steers the NPCs and sends targets, etc to the other clients as needed. If you have big levels and many players, this causes a lot of work for one client. It would be optimal if you don't send each position update but target positions and timings. Your zombies would reach those positions over several frames and then get updates.
    Minimize the individual update data to get best results. It is tedious but on the other hand: Bandwidth and lag can't be changed easily and you have to cope with what's available.
    I would try to steer NPCs via one script that produces only one, lean update for selected AIs (per update loop). This reduces overhead a bit.

    Photon Cloud does not yet support real grouping, so there's no interest management and you can't really save messages/bandwidth by updating only close-by NPCs. But you can skip those that are not doing anything (cause no one is close by).
  • Many, many thanks Tobias for the info - I've been searching the forum for similar information and was finding bits and pieces and still via experimentation trying to get a good handle on what's producing disconnects. I appreciate the beginning tutorials and documentation, hopefully will see more working examples(or will post my own) of understanding the existing limitations or optimizations with networking capacity related to players or agents.

    >The disconnects will happen when you overload the clients with a flash of messages. This can happen, especially when some players spawn a lot of independent objects.

    I did have the masterclient player at game start spawning a zombie AI(with photonview at default rates) every second up to a limit of 20 zombies - this part seemed ok, the disconnect usually happened 2-3 minutes afterward. Could be the extra sustained bandwidth of the 20 new views/messages finally breaking down(queue overload) after a bit.

    >You can use the PhotonStatsGui script to setup a live overview of how many messages/bytes go in and out. Use the inspector to check which parts of the gui you want to see (it's turned off by default). Then work towards less messages.

    Awesomesauce, good to learn about PhotonStatsGui and looking forward to using that diagnostic. Would post that to the cloud references link, for other newbs (if it's not already in some high profile spot in the website/documentation).

    Thanks again,
    Jeremy
  • Going to add a few pics and more info on how to "read" the values but here's a start:
    http://doc.exitgames.com/photon-cloud/P ... working%29
Sign In or Register to comment.