RepNotify triggers even when setting variable to the same value?

I’m working on a Blueprint in Unreal Engine with a RepNotify variable. I thought that if you set a variable to its current value (i.e., it doesn’t actually change), it wouldn’t re-trigger the RepNotify function on the server (listen server).

However, it looks like in my case it does trigger again.

Am I misremembering how RepNotify works, is this expected behavior?

Example:
I went into my Player Character Pawn and created a boolean variable. I didn’t touch anything else, just added a Print String in the OnRep function. When I play the game and press Z several times on the server, the print executes every time (on the server, once on client), even though the variable isn’t actually changing.

You need to be setting the replicated value on the server

It will then keep setting it on the server, but only change it on the client once


As you can see it sets on the server first, then replicates to the client.
On subsequent key presses the client no longer prints

Sorry for the confusion, it was just a quick set up to show what happened on var change on the server side specifically. As you say, the clients shouldn’t modify the replicated variable themselves, but rely on a ROS RPC custom event instead.

My surprise was on the rep notify function triggering multiple times on the server without the value really changing there.

The value is being set each key press, it’s just not re-transmitted to clients to save bandwidth.
You could cache the state on the server and then do a check

Enum

Maybe there might be some extra settings in the input action to filter this out.
Setting it to “Pressed” will reduce it down to 1 fire per key press.