Event Dispatchers are a great way to update UI and control the flow of events without requiring potentially costly busy-wait in Event Tick
. Set up some Event Dispatchers for when variables change, register some events from your UI, and now your UI only updates when your variables change. Efficient and easy to reason about.
However, the situation gets a little more convoluted when replicating variables. The RepNotify setting for variables triggers a OnRep_VAR
function to be called. But only on the server. Similarly, Event Dispatchers cannot be marked as replicated, so Event Dispatchers set up to dispatch in a function/event that changes a variable only work on the current machine (usually server for game-critical variables). This means the flexibility of Event Dispatchers to provide on-demand updating is limited. Currently, I am working around this by marking my variables as RepNotify, then dispatching an RPC to the client from the OnRep_VAR
function, which then calls the EventDispatcher on the client as well. This works, but is a bit boilerplate.
Feature Request: A notification of replication to the client would be extremely useful for keeping the client state, UI, and any other events in sync. As far as I can see it, there are a handful of options to accomplish this task:
- Create a new replication type that would run
OnRep_VAR
on the server and the client. - Allow Event Dispatchers to be marked for replication. Thus, whenever an Event Dispatcher is called, it is replicated as well.
- Some other mechanism to listen for when variables are replicated to owning client. Perhaps explicit registration for event delegates that listen for when a specific variable is replicated.