x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

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!!

Product Version: UE 4.8
Tags:
more ▼

asked Jul 16 '15 at 09:56 AM in C++ Programming

avatar image

Grendert
13 5 14 12

avatar image Pierdek Jul 16 '15 at 10:54 AM

Show us your implementation:

 void CustomController::GetLifetimeReplicatedProps( TArray< FLifetimeProperty > & OutLifetimeProps ) const
avatar image Grendert Jul 16 '15 at 10:59 AM

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!

avatar image Grendert Jul 16 '15 at 11:01 AM

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?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question