[Iris Filtering] Advice on implementing dynamic filtering for various gameplay systems

Question

[Attachment Removed]

Steps to Reproduce
I’m working on a new system for our game that can dynamically change whether or not a particular player actor replicates to a client connection.

This could be extended to dynamically exclude other actors as well such as enemy characters or general objects in the world.

We are using the Iris replication system so I considered creating a Group Filter per player and then filtering out clients that cannot “see” that player.

The problem with this is there is a finite number of Groups you can create and I’d prefer to not depend on this limitation.

We could use a DynamicFilter but we already have a Spatial DynamicFilter applied to all actors.

I could modify this Dynamic Filter to also consider the new gameplay system’s rules as an extra pass but it seems a bit out of place. Thinking to the future, if we ever want to introduce new dynamic filters this wouldn’t be a great pattern to have a single DynamicFilter class that handles a bunch of separate system’s filtering rules.

I could see making a more generically named DynamicFilter that manages a list of sub-filters that extend from some base class.

Then at least we could modularly add new filtering rules for various systems and keep the logic cleaning separated in different class files.

Anyway not sure what the intended usage is and I’d like to avoid reinventing the wheel if there is a more clean way already.

What would you recommend for handling this?

Thanks ahead of time!

[Attachment Removed]

Hi,

What works best will depend on the needs of your project, but I’ll try to provide some more info on dynamic vs group filters that you may find helpful.

When it comes to implementing dynamic filters, we generally recommend against putting “gameplay” code in them, as these don’t have easy access to game objects. Iris tries to maintain a high degree of separation between the gameplay and replication layers, so filters (and prioritizers) should be selectively fed data from gameplay code as needed.

Dynamic filters are also called every frame for every connection in order to determine whether each assigned object should be replicated. This tends to make them more expensive than group filters, which have their results cached and will be very cheap if the group isn’t modified.

It’s also important to note that dynamic filters can be overridden by inclusion groups and dependencies, whereas exclusion groups cannot be overridden by any other kind of filtering.

If you don’t want to allow your filter to be overridden, we would recommend using an exclusion group, especially given that this is likely to be more performant if the group isn’t changed frequently.

Finally, the default max number of groups is 2048. However, this limit is configurable via the NetDriver’s ReplicationSystemConfigServer member, and it can be raised much further, provided it doesn’t exceed FNetObjectGroupHandle::MaxGroupIndexCount (which I believe is 2^24).

Thanks,

Alex

[Attachment Removed]