Everyone says different things about how rep notifies work. The networking compendium says that the rep notify function will always call on every instance of the game (server and clients) whenever the variable is updated. But some people say that it only calls on the clients, and only when the variable actually changes. Others say that it always calls on the clients and only calls on the server if the variable doesn’t change.
Could someone please explain when and where exactly rep notify functions are actually called? I’ve been getting a lot of unexpected behavior with them and I can’t figure out what’s going on.
All the sources you mentioned are in fact correct, as there are a few parameters you need to provide when you ask such a question, with the most important being what type is your OnRep? Is it a C++ or a BP one?
The difference in those two environments stems from the fact that BP OnReps (known as RepNotifys) are in fact not replication callbacks at all. They are just a IPRopertyChangedTracker (in case you have access to C++) and that causes them to fire whenever the variable is set (no matter where), and that’s definitely not a replication callback (like OnReps are in C++).
The only source I’ve found reliable and covers all these nuances is this (which I keep referring to from time to time), which by the sounds of what you said, you should have come upon it, and it should have made things clear for you, not the reverse.
My advice is: Don’t do OnReps in BP unless you’re prototyping or that you don’t do C++ at all. BP RepNotifys are hacky, they will always be.
Fortunately, I’m only using C++ OnReps. I thought that “rep notifies” was the general term for functions that are called whenever a replicated variable is updated. How are they different?
BP OnReps are just a “variable has been set” callback, thus the “it doesn’t matter where is set, it will always fire”, while C++ OnReps are real replication callbacks that will only fire on client when set on server.