Skip to main content

Fusion Interest Management

Summary of Interest Management

Cited from Photon Fusion Documentation :

Interest Management is a set of data culling features, which restrict specific networked element updates from the server to specific clients/players. This culling is useful for reduction of network traffic, as well as restricting player access to data (such as team only information).

To use this feature, please change Replication Mode in Network Project Config to Eventual Consistency replication mode and Enable Object Interest.

Untitled

In Fusion, there are two main network culling mechanism :

  • Object Interest, determine which network object that receive network update from server. there are three way to determine which one receive and which not.

    • All Players

      Will receive network update from all network object.

    • Explicit Players

      Only receive update from explicitly flagged network object.

    • Area of Interest

      Only receive network update from network object with certain radius around it.

  • Interest Groups, allow network object to receive network property update from other network object in same group. Interest group can be assigned by stating it in Default Interest Group

    Set Default Interest Groups in Editor.

    Set Default Interest Groups in Editor.

    ****or assign it manually by code.

    Assign it by accessing SetInterestGroup function in NetworkBehaviour-derived class.

    Assign it by accessing SetInterestGroup function in NetworkBehaviour-derived class.

Research Note

  • Host will always receive network updates regardless of within the AOI radius or not.

    photon-aoi-1.gif

  • For the purpose of Separation of Concern, Interest Management should only handle network-based culling.

  • The default value of Object Interest in Area of Interest mode are false, so if the object instantiated when outside of render radius, it will not spawned in client. it advised when spawning network object who hold data to set it Object Interest to All Players.

    Untitled

  • Setting radius value of AOI too small will caused jittery when network object leave radius (at least on character controller, untested on Rigidbody or Transform movement).

  • Its advisable to further handle network object (especially when there is no choice but to let AOI radius setting small) when leave AOI radius of other network object (like stop rendering the object, deactivate mesh or collider, etc.)

  • Use ISimulationEnter and ISimulationExit interface to check if network object is enter AOI or exit.

  • Interest Group is quite troublesome, since there is no sample correct output or detailed instruction.

  • Server / Host always set to interest to any grouped networked property.

  • The default state of Networked Property who have Group value in it is that every network object that is Observed in that Object Interest is treated as interested in it. this behavior was tested on Object Interest setting to All Players.

  • if the network property is not updated even if we register as interest in it, kindly check that object containing the network property is within the Radius of AOI (if Object Interest is set to Area of Radius), or set that network object interest manually (if Object Interest set to Explicit Player). if somehow both still do not work, then the problem lies somewhere.

  • There are two ways to register in Interest Group, both valid.

    Runner.SetInterestGroup(Object, player, "HiddenMember", false);
    
  • running code snippet above in server environment or client yield desired result (tested on single networked object that contain grouped network property). however, its better to run it on server since that how they (photon) do it.

  • There is no method or parameter to check network object who is set to interest in Interest Group, probably need to create it manually if it is ever needed.

  • Interest Group is tested with case below :

    • There is a single network object who contains a network property called “HiddenNum” and is configured as a member of an Interest Group named “HiddenMember”, each server tick that property is set with a random number. That network object’s Object Interest is configured as All Player for simplicity purpose. some snippet for it.

      public class SingleInterestGroup : NetworkBehaviour, INetworkRunnerCallbacks
      {
          [Networked(group: "HiddenMember")] public int HiddenNum { get; set; }
      
          public override void Spawned()
          {
      				//adding this class as callbacks to already spawn network runner.
              LauncherExtension.AddRunnerCallback(this);
          }
      
          public override void FixedUpdateNetwork()
          {
              if (Runner.IsServer)
              {
                  SetHiddenNum();
              }
          }
      
          public void SetHiddenNum()
          {
              HiddenNum = AssistMe.RandomNumber(1, 9, 1);
          }
      
      #region Network Runner Callbacks
      
      		public void OnPlayerJoined(NetworkRunner runner, PlayerRef player)
      		{
      		        if (runner.IsServer)
      		        {
      								//set player as 'not interest' with this object initially.
      		            Runner.SetInterestGroup(Object, player, "HiddenMember", false);
      		        }
      		 }
      
      //implementing rest of network runner callback below.
      
      #endregion
      }
      
    • Player will display HiddenNum value if player set to interest to HiddenMember.

    • Snippet code for set Interest Group in player side.

      	//use rpc for research purpose. kindly minimize rpc usage if possible.
      	[Rpc(RpcSources.InputAuthority, RpcTargets.StateAuthority)]
      	public void Rpc_SetGroup(PlayerRef pRef, NetworkBool interest)
      	{
      	   JoinGroup = interest;
      
      	   if (Runner.IsServer)
      	        Runner.SetInterestGroup(LauncherExtension.SIG.Object, 
      					Object.InputAuthority, "HiddenMember", JoinGroup);
      	}
      
    • Each player set to not interest with HiddenMember initially.

    • In order to set interest with HiddenMember, press Space, and to set not to interest, press P.

      https://youtu.be/QNplxyBCmsY

  • As for handling multiple network object who contain many grouped network property, it should pose no problem due to Straightforwardness of Interest Group.