RepNotify or Replicated ? Neither one works

Hello,

I have a strange network behavior on a multiplayer game I try to modif. For the record, it’s local game, classic listen-server architecture. Sometimes, a player is connected after session (I execute the Custom Event with the Branch) start and of course, we need to replicate previous changes (a simple door open in my case). So, in a my blueprint, the server set a variable like that :

It doesn’t work, the client always say the variable is false, but the server confirm it’s true… So I try another way with Rep/notify, with same results (RepNotify is not called by the client went I start)


I don’t understand my mistake (s) because I already use this methods with good results.

Thanks for your time !

Well I am no expert but since you only trigger this on the server the client has no way of setting the variable. Also, have you checked that your BP is set to replicate. I the server sets the variable to but the BP is not set to replicate it would ony get set for him(I Would imagine". I sometimes miss this step when making new BPs.

If you want the client to be able to set the variable as well you need to set up a series of NRCs. The multicast call itself isn’t gonna be synced when a new player enters, but the variable that it set will be. Like I said I am not an expert but this is how I understand it.

Hello Bobby and thanks for taking a moment for my problem !

In fact, i don’t want the new client could set the variable (is why I call a Switch Has Authority, to trigger the server only), and yes, the BP is set to replicate. If I replicated a variable with Authority (so on the server), I expect it will be available for the new client. Am I wrong ?

Okay!

Will I guess you are doing things correctly then, but what does your notify function do? Maybe add a print string in there with the new value to see if it gets triggered on the Client?

Basically, I just want to set a boolean by the server (the door is open), it’s why I try two different methods :

  1. Replicate a variable. When to new player start, I put a Branch. The client always failed to read the status…
  2. My variable is a RepNotify and, as my variable was set, I “hope” the function works at the BeginPlay of the new player… Not a better result !

I have spent many hours on this simple task, I’m missing some things…

I get your frustration.

So on point 2 you write that '…“hope” the function works at the BeginPlay of the new player… ’ I don’t understand what you mean. The function will run when the value changes. Are you trying to trigger the function on EventBeginPlay somehow?

Yes, i wasn’t very precise ! This is actually simple : The RepNotify function is set by the server and works perfectly for players in game (every player see the door open). But, when a new player arrives, what happen to the previous order ? The RepNotify who was called before the connection ? I don’t know is the order is lost or waiting be to dispatch.

I am sorry I don’t know what is wrong either, are you testing this by logging in with another computer later on? Not really sure how to test that in the engine(creating another player at runtime).

Don’t be, thanks to have spent time on the question ! I keep looking.

I have found a solution (not sure it’s the best way…), there it is: Like I said before, I have a persistent level with a main BP, controlling all the interactions and variables. Even this BP is set to be replicated, none solutions work (RepNotify or Replicate) when a new player load the game. So I use the persistent level (Level Blueprint) to set and store variables. In my Main BP, when the door opens, I call an Even Dispatchers which are Bind in Level Blueprint and set the variable “Door Opens”.

When the new player arrives, it’s working. Can someone confirm that this is not the best solution?

Check this video out - the demonstration involves opening / closing a chest but it shows examples of how to use multicast / repnotify to handle the logic. The project example is also on GitHub so you can look at the setup at your own pace.

Try setting your door up in a similar way and let me know if you still have questions / can’t get it to work. You should be using the combination of Multicast / RepNotify to handle your door logic (no event dispatchers required). :slight_smile:

@Bry thanks a lot, I find solutions with your work.