and of course the associated variable is marked as ReplicatedUsing.
Now, I assumed (possibly incorrectly) that if a variable was set to push model then is should only replicate to the client if marked as dirty. However, the opposite appears to be true. It seems to be acting like a completely normal variable and replicating as soon as it changes regardless of whether its marked dirty or not.
Is this the intended behaviour? That marking something as dirty doesn’t control overall replication but only speeds us the checking phase of what needs to be replicated? If that’s true is there a way of checking that its actually using push model?
PS: I’ve tried reading the source and reverse engineering what’s happening but its a bit to obfuscated for me to figure out.
All PushModel really does is say “don’t compare this property until I say so”. It’s really more of a server-side optimisations to avoid expensive property comparisons - the savings are minimal at best.
Worth noting though that all parameters are initially considered “dirty”, so it will send at least once (if it differs from the CDO’s default value)
If you type in the console Net.IsPushModelEnabled this will return false, there’s also this macro IS_PUSH_MODEL_ENABLED() also returns false at runtime, so you have to enable push model if I have to guess ?
Oh wow with that setting it actually worked now, this is great thanks for sharing that. I run two tests and it seems to be working as intended with that enabled.
I set a random number, mark the property dirty and it replicates, also print if push mode is enabled, this time it printed true.
The most important thing is it doesn’t replicate if not marked dirty which works. If you have issues getting this to work let me know and I’ll do my best to help.
Ok, seems to be working for me now too! Only difference I was in UE 4.27 before and now I’m in UE 5.0. I don’t know if that was an issue or not but for future readers of this thread I can confirm it’s working in 5.0
Can additionally say that this is what made it all come together.
The advantage here is that you can neglect to enable the pushmodel and replication will still technically work, just not in the way you’re trying to design it. Enabling PushModel just gives it the behavior you’re intending.
Has anyone been able to use this in a packaged game without recompiling the engine? It seems that the engine only defines WITH_PUSH_MODEL 1 for editor builds.
In the .Target.cs file you need to add bWithPushModel = true to the server target.
I tested that this works (assuming you’ve done the params thing and set net.IsPushModelEnabled) on a 5.1.1 source build of the engine, on a dedicated server.