Scene objects and network culling

Options
Hi,
in my game players can fight with mobs. Mobs are scene objects that sync positions via PhotonTransformView

I want to use Photon Network Culling script. It works fine with players (I added NetworkCullingHandler on them).
But what should I do with scene objects so culling works correctly with them? (after master changes other player starts to control them).

Thank you

Comments

  • Hi @webmonch,

    I guess you have to re-run the initialization code from both the OnEnable and the Start function. Maybe adding the OnMasterClientSwitched(PhotonPlayer newMasterClient) callback and do this from inside this callback is already enough, but I'm not sure about that.

    If you have some results about this, please feel free to share them here.
  • webmonch
    Options
    @Christian_Simon thanks for the quick reply!

    I didn't understand fully how culling works here.

    Player subscribes to some areas. So in order to receive updates from scene objects, they must send their data to server with area identifier. Is this photonView.group?

    If this is correct, mobs should have similar script like CullingHandler that sets their groups based on position, BUT they should not call UpdateInterestGroups() as this is needed only for player to receive needed data?

    Also Interest groups impact only receive data? And do they impact rpcs? (e.g.master player is in quad 1, mob is in quad 100. Another player on another pc hits that mob and mob sends rpc to master mob that is in quad that master player is not subscribed to. Will that mob receive rpc or will it be ignored?)

    Sorry for a lot of questions :)
  • Player subscribes to some areas. So in order to receive updates from scene objects, they must send their data to server with area identifier. Is this photonView.group?


    Basically yes. The group variable more ore less describes, to which group the next message will be sent. If you are using a RPC call next, this message will be sent to the group defined in the group variable of the PhotonView component. The same applies for the OnPhotonSerializeView function. There is a difference when using the RaiseEvent function since this one is independent from a PhotonView component. If you want to use RaiseEvent with Interest Groups, this works, too, by using the RaiseEventOptions.

    When a message arrives on the server, it checks the defined group and forwards the message only to the clients, which are subscribed to that specific group. This can be done by using PhotonNetwork.SetInterestGroups(...);.

    If this is correct, mobs should have similar script like CullingHandler that sets their groups based on position, BUT they should not call UpdateInterestGroups() as this is needed only for player to receive needed data?


    I guess you can apply the same component to them. You can also implement a custom solution. Those objects should set their Interest Groups at least one time.

    Also Interest groups impact only receive data?


    It's a combination of sending and receiving. A client will still send all messages to the server, but another client might not receive all of the messages, which is a wanted behaviour in this case.

    And do they impact rpcs?


    Yes. I have mentioned this is in the first answer.

    Will that mob receive rpc or will it be ignored?


    This is related to the setup you have. For example if you call a RPC for group 100 and the 'target' is subscribed to that group, it will receive the message. If the 'target' is not subscribed to that group (maybe you are too far away), it won't receive the RPC. Please note: you are always subscribed to the default group 0 and can't unsubscribe from that group. So any call to this group will always be received by all clients.

    For further reading I would recommend you taking a look at the Culling Demo documentation page which contains a basic description of the related components and the Interest Groups documentation page.