Question about Interest areas

edited July 2010 in Photon Server
I read that you can have multiple interest areas per Item. So I was wondering what is the over head needed for each Interest area? Lets say I wanted player Avatars to each have 5 interest areas:

Interest Area 1: The furthest out interest area, Loads Terrain zones.
Interest Area 2: closer to the avatar then Area 1. used to load trees and larger rocks.
Interest Area 3: closer then area 2. used to load Buildings.
Interest Area 4: closer then area 3. used to show other players, NPCs, and Mobs
Interest Area 5: the closest to the player. Used to show small ground clutter such as small rocks, treasure chests, and corpses.

Would a system like this work or would the overhead needed to run a system like this over-ride any possible gains in performance?


  • BorisBoris ✭✭
    Sure, you can use multiple overlapping interest areas for this purpose. But they should not subscribe to the same item types, otherwise you get the same events multiple times, once per interest area. So on subscribe check if the item type matches what you want to see with that specific interest area, and then subscribe the event channel or not. You need to override OnItemSubscribed and OnItemUnsubscribed in order to do so.
    The overhead is mostly that the overlapped grid cells have to be calculated 5 times instead of just once.
    It shouldn't be too bad for the performance. To gain full control over the used algorithm you can also create a new IWorld implementation and use it instead of the GridWorld.
  • Ok thanks. Good to know. I am first of all trying to get the first Interest area setup. In the Unity MMO Demo where is the starting Interest area size set from? I haven't found any places in both MMOEngine.cs or Player.cs where it is set.
  • BorisBoris ✭✭
    See OnPeerStatusCallback in Photon.MmoDemo.Client.GameStateStrategies.WaitingForConnect.
    The starting interest area is actually set with the EnterWorld operation.
    Note that the MmoDemo is just a demo and that the API is setup to fit its needs.
    If your starting interest area is always the same you could setup the parameters on the server instead of requiring them from the client. Also, you might want to get rid of CreateWorld and initialize your world(s) on application start.
Sign In or Register to comment.