Array OnRepNotify replication doesn't run on server

Hi Staff!

When I set an elem in a replicated array, or add one, the OnRepNotify event doesn’t run on the server, only on the client. Yes, the actor is set to replicated, I set it on the server, and try to print a string then, and only the Client writes it out. It could be reproduced in a clean project. Just press G, while starting it with 2 PIE windows.

It has a long history:

It sais it couldn’t be reproduced, but now it quite is.

Thank you for your time (probably) Kyle!

Hey CrimsonHawk,

I’m looking into the issue, and I’ll respond back as soon as I have an update.

Thanks

No update since then?

Unfortunately, not yet. I’m discussing this with one of the developers, but we were closed for the holiday most of last week. Hopefully I’ll have more information soon.

I appreciate your patience.

Hey CrimsonHawk,

After speaking to our developers, it appears that rep notifies are not called on the server for properties created in c++, but they are called on the server for blueprint properties.

I’ve looked into your project, and used a bit of a different setup that seems to be working on my end. Give it a shot:

116907-arrayrep.png

Let me know if that helps.

Hi!

  1. My project is purely made with Blueprints. I didn’t make anything in C++ for it. If you look at the example project I attached to the question, you can see it is also only made with blueprints.
  2. The RepNotify works as intended with the single variables, but only fires on the client when an array member is set.
  3. This difference between blueprint and C++ makes no sense whatsoever, even if it shouldn’t affect me currently.

With your setup you remake a brand new array from 1 piece of data, and not just changing/adding 1 element in it. This wouldn’t help in any practical situation. This way I could probably make it work, if after every modification I set the NewVar1 to NewVar1. But it also makes no sense at all and the problem would still exist.

(P.s.: I forgot to set the default map to NewMap1, and it has to be opened manually first, but I guess you figured that out already.)


Thanks for working on this bug/question.

I just wanted to provide that information for future use, I understand you’re working in blueprints, but I figured it’d be nice to know in case you ever decide to expand the project to include C++.

After further testing, I’ve gone ahead and entered a bug report. I do believe that this is not working as intended.

Here’s a link to the public bug tracker so you can keep an eye on the status of the issue:

Thanks a lot for your report and for providing a test project.

Let me know if you have any other questions.

Have a great day

Y’d better using Playercontroller to transfer variable to Gamestate : )

What does it have to do with PlayerController and GameState?

U can send variable to PlayerController using custom function , then transfer this variable to Gamestate using custom function too.

I think that you misunderstood the problem. The variable is replicating just fine, the problem is that the event doesn’t run when it happens.

Here is simple example in my project:

121580-1.png

121582-3.png

121583-4.png

At last ,call the variable you want in Gamestate

First of all, your explanation is far from detailed enough to be understandable, secondly this “question” is in the “Bug report” topic. The answers could be either a new/old bug tracker (based on if it is a known issue or not) or an explanation of what mistake I did. Of course a workaround could always be appreciated, but this time I already found mine by calling a custom event manually after every time I change my array. And I still can’t see what does it have to do with transferring variables between objects.

Yep, that is known bug in UE , I just told u the another way to replicate the variable : )

this is not about replicating a variable

this is about a feature not working as it should

the ON REP function of a variable that is set to rep notify should be called when the variable is being changed.

this is not the case however, and even worse it works is some ways and does not in others…

What I can’t understand is how can it be “Backlogged”, since it should be a core feature. Like top priority, since it could potentially affect everyone who is working on any multiplayer project. So if you would be so kind, go to the given link and press a Vote!

I been further testing this. Set array element and add array element do trigger RepNotify, unless they are inside a “For loop”,(a for each or each with break or normal for, doesnt matter wich one). I dunno if this is intended to skip the notify call cuz of the many “simultaneous” calls to the notify or is just a bug.

Did you check the attached project zip? I didn’t use for loop there, and it still didn’t work as it should.

This is a bug that i hope is never fixed. With this bug u can choose when to notify and when not to notify. When using arrays, after a lot of changes this allows you just to notify once, at the end, instead of a lot of notifies in every change you make to a array with set elements or add functions.

Then you are misusing it. Feeding a variable to itself so it would replicate is a very bad use of this feature. What you should do is set the array to non-replicated, and when you finished modifying it call a replicated event that updates this array on the clients. It not only would save some computing and networking resources, but even would make your code more readable.