25+ NPCs that two players can interact with

Options
I'm making a game where a game room will contain 2 players and on the order of 25-40 NPCs that the players can attack. The NPCs have simple behavior with no complex pathfinding requires (just move directly to waypoints), but the players have attacks that can display or change heading of the NPCs.

If I want both players to be able to attack and displace the NPCs, is this possible to do with PUN? If so, how would I go about doing so?

Answers

  • RockingPanda
    Options
    I would attach photon view to all of them (no observed components) and When polayer interacts i would call an RPC to all instacces of that NPC
  • CRho
    Options
    The NPCs also have their own movement (moving from waypoint to waypoint). How would I sync their movement and the results of the RPCs? If the RPCs come when the NPCs are at different positions for different players, then won't they end up desynced?
  • Majicpanda
    Options
    Since one player will be the master client, you're really only sending 40 Transform Views to 1 other player at 20hz, so that's 40x20=800msgs/sec. PUN limits you to 500.

    If you used unity navmesh you could sync destination changes only, but that would eventually get out of sync. You'll have to get a bit clever and experiment with what will keep your messages down.
  • OneManArmy
    OneManArmy ✭✭✭
    edited July 2017
    Options
    @Majicpanda at the end you can see graph:
    https://www.youtube.com/watch?v=wmt_rUSbA_c
    In this video AI synced with RPC's 10 times a second.
    With OnPhotonSerializeView will be easier...
  • Majicpanda
    edited July 2017
    Options
    Are you aggregating all movement into a single send event? 600AI obviously can't be sending their Pos/Rot every net sync because that's 54 bytes per AI and 336k/s outbound traffic per connection?
  • PyeNog
    PyeNog
    edited July 2017
    Options
    @_@
  • OneManArmy
    OneManArmy ✭✭✭
    Options

    Are you aggregating all movement into a single send event?

    yes all in one RPC (4 floats per AI).