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:
-
A client clicks on a button, that calls a server function
-
This function makes sure it’s the server (role == Role_Authority) and then modifies the value of a repnotify variable
-
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!!