Push Model Networking

I’ve been doing some testing with push model networking and I’m facing possible issues.

My code is as follows:

void ABTBS_ProjectileBase::GetLifetimeReplicatedProps(TArray& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);

FDoRepLifetimeParams Params;
Params.bIsPushBased = true;
DOREPLIFETIME_WITH_PARAMS_FAST(ABTBS_ProjectileBase, TrailParticle, Params);

}

void ABTBS_ProjectileBase::SetTrailParticle(UParticleSystem* Particle)
{
MARK_PROPERTY_DIRTY_FROM_NAME(ABTBS_ProjectileBase, TrailParticle, this);
TrailParticle = Particle;
ParticleSystem->SetTemplate(TrailParticle);
}

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.

I’ve read every thread and article I can find on the matter including (🎰 🍲 😅 Unreal Engine 4. New network model: PushModel 👩🏻‍⚖️ 🔅 👐🏽)

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.

Thanks!

1 Like

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)

2 Likes

I’ve done a similar test and the value keeps replicating several times without being marked dirty, any ideas ?

I couldn’t find a solution. I asked on Facebook and Reddit and one person replied on Reddit that they faced the same issue as me.

Thanks for the update, could it be something that only works on packaged ? I’ll keep looking if I find something I’ll rely.

Cheers.

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 ?

I remember updating the .ini file to enable push mode but I didn’t know about those console commands / macros. I’ll explore more. Thanks!

Interesting, do you remember what you had to add to the ini ?

I added this (haven’t had a chance to test what you’ve stated yet):
[SystemSettings]
net.IsPushModelEnabled=1
PS: This was in DefaultEngine.ini

5 Likes

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 tested with a simple int32

I set a random number, mark the property dirty and it replicates, also print if push mode is enabled, this time it printed true.

image

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.

Cheers.

3 Likes

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

3 Likes

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.

1 Like

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.

3 Likes