How to synchronize a Scriptable Object Reference?

I have an effect class whose static information is held in a Scriptable Object EffectData:

public class Effect
{
    [field: SerializeField] public EffectData Data { get; private set; }

    [SerializeField] private EffectType type;
    [SerializeField] private int duration;
}

Now, when an effect is applied to a character, it must be communicated to all other peers in the network. Since the EffectType and the duration are primitive types, I can pass them in an RPC. But how can I synchronize the data? Of course, I don’t want to send all values, but only the reference to the specific Scriptable Object.

As far as I can see, there are two options: Addressables and a custom registry manager. For the latter, I would create something like an EffectManager that contains all the effects and assign a GUID to each. If I use Addressables, I can just pass the address in an RPC.

So my questions are:

  1. are my assumptions correct?
  2. are there other possibilities that I have not considered?
  3. which should i use?
  4. how high is the overhead of an address group for all effects compared to an EffectManager?
  5. is there a minimum number of objects for which it is worth implementing addressables?

You’ll need some sort of “effects registry”.

In its simplest form it is another SO which contains just a

public List<EffectData> Effects;

You can then uniquely identify each effect (or rather effect data) by its index in this list. Since every build has that list you can just marrily send a PlayEffectClientRpc(123) to everyone and they can then look up that effect by index to get its data.

Not a good idea because an addressable address is a string path which could be dozens if not hundreds of bytes long. With an index and at most 255 effects you would instead just send a single byte index.

Preferably the option that uses the least amount of bytes since traffic usage is of utmost importance for a (realtime) network game. Depending on which services the game uses increased traffic may also mean increased payments on your part (ie Relay, Server Hosting, etc).

1 Like