Replication behaviour doubt

Hi.

I’ve been trying to set a variable to repnotify and call a function.

I have a dedicated server and two clients.

The way it works is:

  1. A client clicks on a button, that calls a server function

  2. This function makes sure it’s the server (role == Role_Authority) and then modifies the value of a repnotify variable

  3. The repnotify method get’s called on the client and applies the right behaviour.

Now, the other client doesn’t get called. In order to get called from this function (step 2) I need to search for the server controller of the other client and modifies the variable as well.

I’ve been looking into how to make the variable triggers the function in all the clients without having to change the variable in each server version of the controller and I found the “REPLIFETIME” in which you can add a condition like “only replicates in autonomous proxy clients, or only in simulated proxy” and I tried to set that to None, so it would replicate to all of them, but I still get only one call to the function.

Could anybody explain me if there is something bad with my implementation, or if I understood the repnotify behaviour wrong, or if I do need to change the variable in each controller first to get the function to be called?

Im doing everything in c++

if you need code I can paste it but I don’t have it atm. anyway it would be like

UFunction(server, reliable)
void ButtonPressedBehaviour();

UProperty(ReplicatedUsing=RepNotFunction())
bool replicatedVariable;  //Set to false in constructor

UFunction()
void RepNotFunction();
 bool CustomController::ButtonPressedBehaviour_Validate() 
{
       return true;
}
void CustomController::ButtonPressedBehaviour_Implementation() 
{
   if(Role == Role_Authority)
   {
         replicatedVariable = !ReplicatedVariable;
   }
}

void CustomController::RepNotFunction()
{
    if(Role < Role_Authority)   //Putting a breakpoint here only gets called once I know on the server on c++ it won't get called unless I make it call it but shouldn't the other client call this as well ? 
        DoStuff;
   
}

Thanks!!

Show us your implementation:

void CustomController::GetLifetimeReplicatedProps( TArray< FLifetimeProperty > & OutLifetimeProps ) const

This function would be like that atm

void CustomController::GetLifetimeReplicatedProps( TArray< FLifetimeProperty > & OutLifetimeProps ) const
{
	Super::GetLifetimeReplicatedProps( OutLifetimeProps );
 
	DOREPLIFETIME(CustomController, replicatedVariable);

      //I've also tried
      //DOREPLIFETIME_CONDITION( CustomController, replicatedVariable, COND_None); and with COND_SimulatedOnly or COND_AutonomousOnly	
}

Is that what you were asking for I guess?
Thanks for answering!

I was just thinking… could it be that since I created my own custom button and added to the viewport on the client, each client has a different HUD, and only one pressed the button that triggered the server function “ButtonPressedBehaviour” so only one of the server version of the controllers goes through it?